
I'm trying to use the function traits to extract the return type of a template parameter, but it's not compiling.
Any ideas what's wrong here?
Yes, function_traits takes a function type as parameter, *not* a function pointer type: function_traits<int (int, double)> // OK function_traits<int (*)(int, double)> // not OK. So throw in a remove_pointer into your code and everything should be well:
-------- begin simplified code ------
template<typename Proc> class CacheValue { typedef boost::remove_pointer<Proc>::type np_type; typedef boost::function_traits<np_type>::R ReturnType; template<typename Arg1> ReturnType operator () ( Arg1 arg1 ) { /* do something */ } }; CacheValue<unsigned long (*) ( unsigned long )> aValue;
-------- end simplified code ------
John Maddock http://ourworld.compuserve.com/homepages/john_maddock/index.htm