File tree 1 file changed +14
-0
lines changed
1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 26
26
27
27
#include < type_traits>
28
28
29
+ #if __has_include(<utility>) // For C++23 and later, include <utility> if available
30
+ #include < utility> // Contains std::to_underlying
31
+ #endif
32
+
29
33
namespace chip {
30
34
35
+ #if __cplusplus >= 202300L
36
+
37
+ template <class T >
38
+ constexpr auto to_underlying (T e)
39
+ {
40
+ return std::to_underlying (e);
41
+ }
42
+
43
+ #else
31
44
/* *
32
45
* @brief Implemented std::to_underlying introduced in C++23.
33
46
*/
@@ -37,6 +50,7 @@ constexpr std::underlying_type_t<T> to_underlying(T e)
37
50
static_assert (std::is_enum<T>::value, " to_underlying called to non-enum values." );
38
51
return static_cast <std::underlying_type_t <T>>(e);
39
52
}
53
+ #endif
40
54
41
55
/* *
42
56
* @brief This template is not designed to be used directly. A common pattern to check the presence of a member of a class is:
You can’t perform that action at this time.
0 commit comments