Belov Belov - 1 month ago 16
C++ Question

C++ template OR operator?

So I need something like an OR operator inside the argument of a template,
e.g. I want to do the following:

template <typename T, typename F,
typename = std::enable_if<
!std::is_same<T, Node>::value> or !std::is_same<F, Node>::value>>


In other words I need the function to exists when one of the
T
and
F
template class is not
Node
.

But currently that gives me compile error.

PS: I've edited the original question to make it more clear.

Answer

You can use std::disjunction

std::enable_if<std::disjunction<a, b>::value>

However as mentioned in the comments, a and b must be constexpr, not values only known at runtime.

Comments