From a3ae58c9c501245ebcc18bb346837fa53e851174 Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Sun, 26 Jan 2025 13:48:35 +0100 Subject: C++ features: add cm::is_scoped_enum from C++23 --- Help/dev/source.rst | 5 +++++ Utilities/std/cm/type_traits | 31 ++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Help/dev/source.rst b/Help/dev/source.rst index c3c55a3..fd8597d 100644 --- a/Help/dev/source.rst +++ b/Help/dev/source.rst @@ -221,6 +221,11 @@ Available features are: * ````: ``cm::erase``, ``cm::erase_if``, ``cm::ssize`` +* From ``C++23``: + + * ````: + ``cm::is_scoped_enum`` + Additionally, some useful non-standard extensions to the C++ standard library are available in headers under the directory ``cmext/`` in namespace ``cm``. These are: diff --git a/Utilities/std/cm/type_traits b/Utilities/std/cm/type_traits index 56ec64f..b0ee27a 100644 --- a/Utilities/std/cm/type_traits +++ b/Utilities/std/cm/type_traits @@ -23,7 +23,7 @@ using enable_if_t = typename std::enable_if::type; #endif -#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703) +#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) // Helper classes using std::bool_constant; @@ -57,4 +57,33 @@ using void_t = typename make_void::type; #endif +#if (__cplusplus >= 202302L || \ + (defined(_MSVC_LANG) && _MSVC_LANG >= 202302L)) && \ + __cpp_lib_is_scoped_enum == 202011L + +using std::is_scoped_enum; + +#else + +namespace internals { +template ::value> +struct is_scoped_enum_helper : std::false_type +{ +}; + +template +struct is_scoped_enum_helper + : public cm::bool_constant< + !std::is_convertible::type>::value> +{ +}; +} + +template +struct is_scoped_enum : public internals::is_scoped_enum_helper +{ +}; + +#endif + } // namespace cm -- cgit v0.12