Belov Belov - 1 year ago 91
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
template class is not

But currently that gives me compile error.

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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download