how to detect if a type is among a know list inside enable_if
Hi, I need to enable only if a type T is among a specific known list. I tried to build an operator is_one_of< T, list of known types > condition that could be used within an enable_if (like others type_traits operators), like this: or< is_same< T, type1 >, or< is_same< T, type2>, ... > so I searched for an or< condition1, condition2> construct and didn't find anything... Thanks for your suggestions! Claude
AMDG Claude Brisson wrote:
I need to enable only if a type T is among a specific known list.
I tried to build an operator is_one_of< T, list of known types > condition that could be used within an enable_if (like others type_traits operators), like this:
or< is_same< T, type1 >, or< is_same< T, type2>, ... >
so I searched for an or< condition1, condition2> construct and didn't find anything...
It's boost::mpl::or_ (Note that or is a keyword)
However, in this case, it's easier to use mpl::set:
#include
::type f(const T&) {}
int main() { f(1); // ok f("test"); // fails } In Christ, Steven Watanabe
participants (2)
-
Claude Brisson
-
Steven Watanabe