diff options
author | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2025-05-08 00:15:26 +0200 |
---|---|---|
committer | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2025-05-08 00:15:26 +0200 |
commit | e1ba7dd7a976b2ce076b9361f761dd51cdf4b4ec (patch) | |
tree | 80c76c46ee2678aa39280220d1d6f82bed98ef1c /asl/base/utility.hpp | |
parent | 837f696971677b4ed2263e744a9ce6d6d3865b11 (diff) |
Add enum underlying utilities
Diffstat (limited to 'asl/base/utility.hpp')
-rw-r--r-- | asl/base/utility.hpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/asl/base/utility.hpp b/asl/base/utility.hpp index f371ab4..c4801b1 100644 --- a/asl/base/utility.hpp +++ b/asl/base/utility.hpp @@ -69,6 +69,12 @@ constexpr U bit_cast(T value) requires (sizeof(T) == sizeof(U)) return __builtin_bit_cast(U, value); } +template<is_enum T> +constexpr auto to_underlying(T value) +{ + return static_cast<underlying_t<T>>(value); +} + // NOLINTBEGIN(*-macro-parentheses) #define ASL_DELETE_COPY(T) \ T(const T&) = delete; \ |