Is it possible to determine if a type is a scoped enumeration type?

后端 未结 1 1158
逝去的感伤
逝去的感伤 2020-11-28 12:18

Is there a type trait, or is it possible to write a type trait is_scoped_enum such that:

  • if T is a scoped enumeration,
1条回答
  •  清酒与你
    2020-11-28 12:33

    I think testing if it is an enum and not implicitly convertible to the underlying type should do the trick.

    template ::value>
    struct is_scoped_enum : std::false_type {};
    
    template 
    struct is_scoped_enum
    : std::integral_constant::type>::value> {};
    

    0 讨论(0)
提交回复
热议问题