2

I have the following

template <typename F, typename A0>
struct ResultOf {
        typedef typename decltype(boost::declval<F>()(boost::declval<A0>())) Type;
};

It was written so that VS2010 could have a result_of that worked for a specific use case. It is working under vs2015, vs2013 and vs2010 but under gcc I get a compile error

error: expected nested-name-specifier before ‘decltype’
typedef typename decltype(boost::declval<F>()(boost::declval<A0>())) Type;

Is there an obvious small fix here?

bradgonesurfing
  • 30,949
  • 17
  • 114
  • 217

2 Answers2

2

typename keyword is not needed here. It is used, in particular, to denote a dependent type, like T::value_type, when a compiler cannot know whether value_type is a type. There are no dependent types in the present case.

Evg
  • 25,259
  • 5
  • 41
  • 83
2

Removing the typename works in clang, gcc, and modern msvc:

https://godbolt.org/z/CfOw-_

xaxxon
  • 19,189
  • 5
  • 50
  • 80