From 517916fa533469e7cd89200392a5a4ad946a1bf9 Mon Sep 17 00:00:00 2001 From: Redstone1024 <2824517378@qq.com> Date: Thu, 3 Oct 2024 23:48:50 +0800 Subject: [PATCH] refactor(miscellaneous): refactor the definitions of floating-point types and character types --- .../Source/Public/Miscellaneous/Platform.h | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Redcraft.Utility/Source/Public/Miscellaneous/Platform.h b/Redcraft.Utility/Source/Public/Miscellaneous/Platform.h index 6d7387f..35e0f09 100644 --- a/Redcraft.Utility/Source/Public/Miscellaneous/Platform.h +++ b/Redcraft.Utility/Source/Public/Miscellaneous/Platform.h @@ -6,6 +6,10 @@ #include #include +#if __cplusplus >= 202300L +# include +#endif + NAMESPACE_REDCRAFT_BEGIN NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Utility) @@ -156,8 +160,40 @@ using int64 = NAMESPACE_STD::int64_t; // Floating point types +#if defined(__STDCPP_FLOAT16_T__) +using float16 = NAMESPACE_STD::float16_t; +#endif + +#if defined(__STDCPP_FLOAT32_T__) +using float32 = NAMESPACE_STD::float32_t; +#else using float32 = float; +#endif + +#if defined(__STDCPP_FLOAT64_T__) +using float64 = NAMESPACE_STD::float64_t; +#else using float64 = double; +#endif + +#if defined(__STDCPP_FLOAT128_T__) +using float128 = NAMESPACE_STD::float128_t; +#endif + +#if defined(__STDCPP_BFLOAT16_T__) +using bfloat16 = NAMESPACE_STD::bfloat16_t; +#endif + +static_assert(sizeof(float32) == 4); +static_assert(sizeof(float64) == 8); + +// Character types + +using wchar = wchar_t; +using u8char = char8_t; +using u16char = char16_t; +using u32char = char32_t; +using unicodechar = char32_t; // Pointer types