1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:37:35 +00:00

AK: Add Integral and FloatingPoint concepts.

This commit is contained in:
asynts 2020-08-03 20:14:37 +02:00 committed by Andreas Kling
parent 05abfc0e1f
commit 5f7427ba4b
2 changed files with 78 additions and 0 deletions

View file

@ -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;