Get result type of function

Posted by Robert on Stack Overflow See other posts from Stack Overflow or by Robert
Published on 2011-01-10T14:34:31Z Indexed on 2011/01/10 14:53 UTC
Read the original article Hit count: 126

Filed under:
|
|
|

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 ?

© Stack Overflow or respective owner

Related posts about c++

Related posts about function