所在头文件:#include
result_of() 函数使用到了模板元编程技术,对于F(Arg1, Arg2, ..., Argn),F是一个可调用对象f(函数指针,函数引用,成员函数指针,或函数对象)的类型,Argn是其参数argn的类型,那么result_of
例子:
#include#include int fn(int) {return int();} // function typedef int(&fn_ref)(int); // function reference typedef int(*fn_ptr)(int); // function pointer struct fn_class { int operator()(int i){return i;} }; // function-like class int main() { typedef std::result_of ::type A; // int typedef std::result_of ::type B; // int typedef std::result_of ::type C; // int typedef std::result_of ::type D; // int std::cout << std::boolalpha; std::cout << "typedefs of int:" << std::endl; std::cout << "A: " << std::is_same ::value << std::endl; std::cout << "B: " << std::is_same ::value << std::endl; std::cout << "C: " << std::is_same ::value << std::endl; std::cout << "D: " << std::is_same ::value << std::endl; return 0; }



