これだとOKだけど
#include <iostream> #include <boost/utility/result_of.hpp> using namespace std; struct hoge { typedef int result_type; int operator()(double d) const { return 0; } }; int main() { cout << typeid(boost::result_of<hoge(double)>::type).name() << endl; return 0; }
これだとNG
#include <iostream> #include <boost/utility/result_of.hpp> using namespace std; struct hoge { struct result { typedef int type; }; int operator()(double d) const { return 0; } }; int main() { cout << typeid(boost::result_of<hoge(double)>::type).name() << endl; // 'result' : シンボルはクラス テンプレート でも関数 テンプレート でもありません return 0; }
あれー?、関数オブジェクトの戻り値の型って struct result 作ってできるんじゃなかったっけ?
result_of は情報少ないなー
A uniform method for computing function object return types (revision 1)
# 追記 : これで通った
struct hoge { template <class T> struct result { typedef int type; }; int operator()(double d) const { return 0; } };