In the C++ standard library, are there template types that are boolean operations on integral_constant<bool, X>
(where X
is either true
or false
)?
As a simple example, you have two overloads of a function as such:
void foo_impl(false_type){
cout << "false" <<endl;
}
void foo_impl(true_type){
cout << "true" <<endl;
}
One of these functions is chosen by another function, based on a constant condition:
struct first_tag{};
struct second_tag{};
struct third_tag{};
template <typename TTag>
void foo(TTag role){
foo_impl(typename constant_or<typename is_same<role, first_tag>::type, typename is_same<role, second_tag>::type>::type{});
}
In this case, the true
version of foo_impl()
is to be be called if the parameter to foo()
is of type first_tag
or second_tag
, hence the use of a hypothetical type constant_or
.
While it is simple to write my own version of constant_or
, does such a type already exist in the C++ standard library?