mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:17:34 +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
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…
Add table
Add a link
Reference in a new issue