65,187
社区成员




//gcc 的一个有参构造函数
template<typename _Functor,
typename = _Requires<__not_<is_same<_Functor, function>>, void>, //要求_Functor不能是function类型,因为已经有另一个拷贝构造
typename = _Requires<_Callable<_Functor>, void>> //重点是这行的_Callable模板类
function(_Functor);
再看_Callable模板类,关键是__check_func_return_type模板类
template<typename _Func,
typename _Res2 = typename result_of<_Func&(_ArgTypes...)>::type>
struct _Callable : __check_func_return_type<_Res2, _Res> { };
再看__check_func_return_type模板类,看这个名字就好懂:is_void is_same is_convertible
template<typename _From, typename _To>
using __check_func_return_type
= __or_<is_void<_To>, is_same<_From, _To>, is_convertible<_From, _To>>;