C ++ template defines type of function returned

How can I determine the return type of a common function of an element?

template<class E> struct result<E> { // E has member function data(), I need to know its return type typedef typename &E::data type; }; 

Can this be done in a general way? I know that there is boost:: result_of , but for my purposes it lacks specializations (if I understand correctly, the return type must be specialized). speeding up the implementation would be great.

+6
c ++ templates
source share
2 answers

The GCC custom typeof operator can do this, and Boost.TypeOf .

+4
source share

If you are using VS2010 or GCC 4.3, at least you can use the C ++ 0x decltype .

+3
source share

All Articles