mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: Add a function that casts an enum to its underlying type
This is basically the same thing as `std::to_underlying(Enum)`.
This commit is contained in:
parent
dac971b4ae
commit
f7f88adc78
Notes:
sideshowbarker
2024-07-18 12:13:24 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/f7f88adc78b Pull-request: https://github.com/SerenityOS/serenity/pull/8023 Reviewed-by: https://github.com/awesomekling
1 changed files with 7 additions and 0 deletions
|
@ -110,6 +110,12 @@ constexpr T exchange(T& slot, U&& value)
|
|||
template<typename T>
|
||||
using RawPtr = typename Detail::_RawPtr<T>::Type;
|
||||
|
||||
template<typename V>
|
||||
constexpr decltype(auto) to_underlying(V value) requires(IsEnum<V>)
|
||||
{
|
||||
return static_cast<UnderlyingType<V>>(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
using AK::array_size;
|
||||
|
@ -121,3 +127,4 @@ using AK::max;
|
|||
using AK::min;
|
||||
using AK::RawPtr;
|
||||
using AK::swap;
|
||||
using AK::to_underlying;
|
||||
|
|
Loading…
Reference in a new issue