前置依赖:

  1. integral_constant
  2. conditional

实现源码:

// 类型逻辑运算 or
template<typename...>
    struct __or_;

template<>
    struct __or_<>
    : public false_type
    { };

template<typename _B1>
    struct __or_<_B1>
    : public _B1
    { };

template<typename _B1, typename _B2>
    struct __or_<_B1, _B2>
    : public conditional<_B1::value, _B1, _B2>::type
    { };

template<typename _B1, typename _B2, typename _B3, typename... _Bn>
    struct __or_<_B1, _B2, _B3, _Bn...>
    : public conditional<_B1::value, _B1, __or_<_B2, _B3, _Bn...>>::type
    { };

再次强调, 返回结果是 integral_constant 对象实例, 为 true_type 或者 false_type, 而不是简单的 bool 类型, 这里就是使用了 integral_constant 中的 type 接口