如何在多个条件下使用 std::enable_if 的示例

只需像这样使用 &&

enable_if_example_declaration.cpp
std::enable_if<CONDITION1::value && CONDITION2::value, T>

完整示例:

enable_if_full_example.cpp
template<class T, class I>
constexpr typename std::enable_if<std::is_enum<T>::value && std::is_integral<I>::value, I>::type operator|(T lhs, I rhs)
{
    return static_cast<typename std::underlying_type<T>::type>(lhs) | rhs;
}

Check out similar posts by category: C/C++