I have a class that takes a bool template parameter. The class will have several methods which I need to specialize on the class bool template parameter. Is there a way of doing this without specialising the whole class itself?
Foo::bar() below is an example of what I mean, it does not work since std::is_same works with types and not values
Thanks.
template<bool Mode>
class Foo
{
public:
template<bool M=Mode, typename std::enable_if<std::is_same<M,true>::value>::type * = 0>
void bar()
{
std::cout << "true" << std::endl;
}
template<bool M=Mode, typename std::enable_if<std::is_same<M,false>::value>::type * = 0>
void bar()
{
std::cout << "false" << std::endl;
}
std::is_samecompares types.Mis a constant,trueandfalseare values, i.e. they're not types. - dyp