1

In an attempt to use SFINAE, the following code fails to compile:

template<typename ObjectType, typename GroupA, typename GroupB, typename = void>
struct DelegateImpl; // default version

template<typename ObjectType, typename GroupA, typename GroupB>
struct DelegateImpl<ObjectType, GroupA, GroupB, decltype(GroupA::get<ObjectType>())>; // specialization

With GCC:

error: template argument 4 is invalid

With MSVC, a surprisingly more helpful:

error C3553: decltype expects an expression not a type

My aim is to have the compiler pick the specialization if the expression GroupA::get<ObjectType>() is valid.

Question: How do I use decltype with a static template method?

dgrine
  • 702
  • 6
  • 15
  • Possible duplicate of: [Where and why do I have to put the "template" and "typename" keywords?](http://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords). – n. m. could be an AI May 09 '16 at 10:03

1 Answers1

6

Neither compilers give helpful errors actually. The real issue is you're missing the template keyword before get:

template get<ObjectType>()

See cppreference's page on Dependent Names