Home Specialize template which includes enableif
Reply: 0

Specialize template which includes enableif

user1331 Published in April 24, 2018, 8:34 am

I want to specialize a templated method. It makes use of std::enable_if to check a static property of the given type:

template <class T, bool fancy= T::IsFancy()>
typename std::enable_if<fancy, void>::type
onlyForFancyGuys(T* component) {

As I use this for recursive calls, I need a way to determine, when recursion ends. That is, when type Foo is used. So I tried this specialization.

typename void onlyForFancyGuys<Foo, true>(Foo* component);


void onlyForFancyGuys<Foo, true>(Foo* component);

But it keeps telling, me that this template-id does not match any template declaration. What am I doing wrong here? Is there something specific with enable_if?

Important fact: Foo does not have the method IsFancy.

Edit: I added IsFancy to Foo, but it does not make any difference.

Edit: I am compiling with MinGW. But I plan to use MSVC, too.

Edit: Adding IsFancy to Foo together with the accepted answer did the trick.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.499912 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO