Get result type of function
- by Robert
I want to specialize a template function declared as:
template<typename Type> Type read(std::istream& is);
I then have a lot of static implementations
static int read_integer(std::istream& is);
a.s.o. Now I'd like to do a macro so that specialization of read is as simple as:
SPECIALIZE_READ(read_integer)
So I figured I'd go the boost::function_traits way and declare SPECIALIZE_READ as:
#define SPECIALIZE_READ(read_function) \
template<> boost::function_traits<read_function>::result_type read(std::istream& is) { \
return read_function(is); \
}
but VC++ (2008) compiler complains with: 'boost::function_traits' : 'read_integer' is not a valid template type argument for parameter 'Function'
Ideas ?