Last Updated: February 25, 2016
·
654
· miguelibero

SFINAE replacement for std::result_of

The gnu C++11 implementation of std::result_of does not contain the typedef type for methods that return void. This does not comply with the SFINAE policy. Heres a simple replacement for the type trait that does work.

template<typename Expr>
class result_of;

template<typename F, typename... Args>
struct result_of<F(Args...)>
{
  typedef decltype(std::declval<F>()(std::declval<Args>()...)) type;
};