mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 08:27:46 +00:00
AK: Make IndexSequence use size_t
This makes it possible to use MakeIndexSequqnce in functions like: template<typename T, size_t N> constexpr auto foo(T (&a)[N]) This means AK/StdLibExtraDetails.h must now include AK/Types.h for size_t, which means AK/Types.h can no longer include AK/StdLibExtras.h (which arguably it shouldn't do anyways), which requires rejiggering some things. (IMHO Types.h shouldn't use AK::Details metaprogramming at all. FlatPtr doesn't necessarily have to use Conditional<> and ssize_t could maybe be in its own header or something. But since it's tangential to this PR, going with the tried and true "lift things that cause the cycle up to the top" approach.)
This commit is contained in:
parent
1c7ec9c770
commit
4409b33145
20 changed files with 120 additions and 96 deletions
80
AK/Types.h
80
AK/Types.h
|
@ -7,7 +7,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Platform.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
|
||||
using u64 = __UINT64_TYPE__;
|
||||
using u32 = __UINT32_TYPE__;
|
||||
|
@ -34,6 +33,85 @@ using f128 = long double;
|
|||
# endif
|
||||
#endif
|
||||
|
||||
namespace AK::Detail {
|
||||
|
||||
// MakeSigned<> is here instead of in StdLibExtras.h because it's used in the definition of size_t and ssize_t
|
||||
// and Types.h must not include StdLibExtras.h to avoid circular dependencies.
|
||||
template<typename T>
|
||||
struct __MakeSigned {
|
||||
using Type = void;
|
||||
};
|
||||
template<>
|
||||
struct __MakeSigned<signed char> {
|
||||
using Type = signed char;
|
||||
};
|
||||
template<>
|
||||
struct __MakeSigned<short> {
|
||||
using Type = short;
|
||||
};
|
||||
template<>
|
||||
struct __MakeSigned<int> {
|
||||
using Type = int;
|
||||
};
|
||||
template<>
|
||||
struct __MakeSigned<long> {
|
||||
using Type = long;
|
||||
};
|
||||
template<>
|
||||
struct __MakeSigned<long long> {
|
||||
using Type = long long;
|
||||
};
|
||||
template<>
|
||||
struct __MakeSigned<unsigned char> {
|
||||
using Type = char;
|
||||
};
|
||||
template<>
|
||||
struct __MakeSigned<unsigned short> {
|
||||
using Type = short;
|
||||
};
|
||||
template<>
|
||||
struct __MakeSigned<unsigned int> {
|
||||
using Type = int;
|
||||
};
|
||||
template<>
|
||||
struct __MakeSigned<unsigned long> {
|
||||
using Type = long;
|
||||
};
|
||||
template<>
|
||||
struct __MakeSigned<unsigned long long> {
|
||||
using Type = long long;
|
||||
};
|
||||
template<>
|
||||
struct __MakeSigned<char> {
|
||||
using Type = char;
|
||||
};
|
||||
#if ARCH(AARCH64)
|
||||
template<>
|
||||
struct __MakeSigned<wchar_t> {
|
||||
using Type = void;
|
||||
};
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
using MakeSigned = typename __MakeSigned<T>::Type;
|
||||
|
||||
// Conditional<> is here instead of in StdLibExtras.h because it's used in the definition of FlatPtr
|
||||
// and Types.h must not include StdLibExtras.h to avoid circular dependencies.
|
||||
template<bool condition, class TrueType, class FalseType>
|
||||
struct __Conditional {
|
||||
using Type = TrueType;
|
||||
};
|
||||
|
||||
template<class TrueType, class FalseType>
|
||||
struct __Conditional<false, TrueType, FalseType> {
|
||||
using Type = FalseType;
|
||||
};
|
||||
|
||||
template<bool condition, class TrueType, class FalseType>
|
||||
using Conditional = typename __Conditional<condition, TrueType, FalseType>::Type;
|
||||
|
||||
}
|
||||
|
||||
#ifdef AK_OS_SERENITY
|
||||
|
||||
using size_t = __SIZE_TYPE__;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue