function object研究之十三 result_traits

来源:互联网 发布:如何评价柳海龙 知乎 编辑:程序博客网 时间:2024/06/05 12:44

result_traits模板定义在bind.hpp中,属于_bi namespace中。

// result_traitstemplate<class R, class F> struct result_traits{    typedef R type;};#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)struct unspecified {};template<class F> struct result_traits<unspecified, F>{    typedef typename F::result_type type;};template<class F> struct result_traits< unspecified, reference_wrapper<F> >{    typedef typename F::result_type type;};

第一个模板定义R为type

第二个和第三个都要求F类型具有内部定义的result_type。


这个模板很简单,就是要产生result_traits<T...>::type 类型作为返回类型。


原创粉丝点击