Boost has both enable_if
and disable_if
, but C++0x seems to be missing the latter. Why was it left out? Are there meta-programming facilities in C++0x that allow me to build disable_if
in terms of enable_if
?
Oh, I just noticed that std::enable_if
is basically boost::enable_if_c
, and that there is no such thing as boost::enable_if
in C++0x.
At the risk of seeming stupid, just do !expression
instead of expression
in the bool template parameter in enable_if
to make it behave like a disable_if
? Of course if that idea works, you could just expand on it to write a class with disable_if
-like behavior?
Ok, I believe you could implement disable_if
like this:
template <bool B, typename T = void>
struct disable_if {
typedef T type;
};
template <typename T>
struct disable_if<true,T> {
};