Skip to content

<type_traits>: Possible improvements of implementation strategy of is_scoped_enum #5333

@frederick-vs-ja

Description

@frederick-vs-ja
  1. Clang has implemented the __is_scoped_enum intrinsic since Clang 16 (llvm/llvm-project@a089def, LLVM-D135177). But MSVC and EDG don't seem to have it implemented. Should we use __is_scoped_enum for Clang, which possibly improve throughput?
  2. As noticed in <type_traits>: Implement is_scoped_enum #1950, MSVC thinks that an unscoped enumeration type without fixed underlying type is complete in its enumerator-list (and generally treats int as its underlying type). This is non-conforming, while a conformance fix is likely to break the current implementation strategy. I think I've found the strategy (see below) working with both conforming and non-conforming treatments. Should we use it or something similar?
void _Test_convertibility_for_is_scoped_enum(...); // not defined
void _Test_convertibility_for_is_scoped_enum(int) = delete;

template <class _Ty>
concept _Is_scoped_enum_impl = __is_enum(_Ty) && requires { _STD _Test_convertibility_for_is_scoped_enum(_Ty{}); };

_EXPORT_STD template <class _Ty>
struct is_scoped_enum : bool_constant<_Is_scoped_enum_impl<_Ty>> {};

_EXPORT_STD template <class _Ty>
constexpr bool is_scoped_enum_v = _Is_scoped_enum_impl<_Ty>;

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSomething can be improvedfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions