diff options
author | asynts <asynts@gmail.com> | 2020-08-03 20:14:37 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-06 10:33:16 +0200 |
commit | 5f7427ba4bfeb28b608b1e6e98046bbc0e54730d (patch) | |
tree | 4ac6b9e1e5aac47112fc3eadeb55aed9d0a7dfb9 /AK/StdLibExtras.h | |
parent | 05abfc0e1f7e349d8a29a2902cfd220cf9b6d9dc (diff) | |
download | serenity-5f7427ba4bfeb28b608b1e6e98046bbc0e54730d.zip |
AK: Add Integral and FloatingPoint concepts.
Diffstat (limited to 'AK/StdLibExtras.h')
-rw-r--r-- | AK/StdLibExtras.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/AK/StdLibExtras.h b/AK/StdLibExtras.h index bfaaa4aac1..b47a465fd1 100644 --- a/AK/StdLibExtras.h +++ b/AK/StdLibExtras.h @@ -26,6 +26,11 @@ #pragma once +typedef __UINT64_TYPE__ u64; +typedef __UINT32_TYPE__ u32; +typedef __UINT16_TYPE__ u16; +typedef __UINT8_TYPE__ u8; + #define UNUSED_PARAM(x) (void)x inline constexpr unsigned round_up_to_power_of_two(unsigned value, unsigned power_of_two) @@ -455,6 +460,36 @@ template<typename Base, typename Derived> struct IsBaseOf : public IntegralConstant<bool, __is_base_of(Base, Derived)> { }; +template<typename T> +struct __IsIntegral : FalseType { +}; +template<> +struct __IsIntegral<u8> : TrueType { +}; +template<> +struct __IsIntegral<u16> : TrueType { +}; +template<> +struct __IsIntegral<u32> : TrueType { +}; +template<> +struct __IsIntegral<u64> : TrueType { +}; +template<typename T> +using IsIntegral = __IsIntegral<typename MakeUnsigned<typename RemoveCV<T>::Type>::Type>; + +template<typename T> +struct __IsFloatingPoint : FalseType { +}; +template<> +struct __IsFloatingPoint<float> : TrueType { +}; +template<> +struct __IsFloatingPoint<double> : TrueType { +}; +template<typename T> +using IsFloatingPoint = __IsFloatingPoint<typename RemoveCV<T>::Type>; + template<typename ReferenceType, typename T> using CopyConst = typename Conditional<IsConst<ReferenceType>::value, typename AddConst<T>::Type, typename RemoveConst<T>::Type>::Type; |