I\'m looking for a way in C++ to extract the return type of a function (without calling it). I presume this will require some template magic.
float Foo();
i
Foo and Bar are functions, not function types, so you need to do a bit of extra work.
Here's a solution using a combination of boost::function_traits and BOOST_TYPEOF.
#include
#include
float Foo();
int Bar();
int main()
{
boost::function_traits::result_type f = 5.0f;
boost::function_traits::result_type i = 1;
return i;
}
Edit: