-
Couldn't load subscription status.
- Fork 15k
Description
The C++23 <stdfloat> header is still missing, but this header is easy to implement in libc++.
In the libstdc++ 13 and later implementation of in C++23 or later mode, std::float16_t is a typedef for _Float16 if __STDCPP_FLOAT16_T__ is defined, std::float32_t is a typedef for _Float32 if __STDCPP_FLOAT32_T__ is defined, std::float64_t is a typedef for _Float64 if __STDCPP_FLOAT64_T__ is defined, and std::float128_t is a typedef for _Float128 if __STDCPP_FLOAT128_T__ is defined.
std::is_same_v<std::float32_t, float> is always false in libstdc++ 13 and later, even though std::float32_t and float both usually have the same format, size, and alignment.
std::is_same_v<std::float64_t, double> is always false in libstdc++ 13 and later, even though std::float64_t and double both usually have the same format, size, and alignment.
The std::numeric_limits<std::float32_t> and std::numeric_limits<std::float64_t> specializations are easy to implement (assuming std::float32_t has the same format as float and std::float64_t has the same format as double) as std::numeric_limits<std::float32_t> can usually use the same values as std::numeric_limits<float> (but with std::float32_t used instead of float for floating-point values in the std::numeric_limits<std::float32_t> specialization) and as std::numeric_limits<std::float64_t> can usually use the same values as std::numeric_limits<double> (but with std::float64_t used instead of double for floating-point values in the std::numeric_limits<std::float64_t> specialization).
Clang 21 already defines the __FLT16_MANT_DIG__, __FLT16_DIG__, __FLT16_MIN__, __FLT16_MAX__, __FLT16_EPSILON__, __FLT16_MIN_EXP__, __FLT16_MIN_10_EXP__, __FLT16_MAX_EXP__, __FLT16_MAX_10_EXP__, __FLT16_DENORM_MIN__ macros needed to implement the std::numeric_limits<std::float16_t> specialization.
In addition to adding the <stdfloat> header to libc++, also need to update the Clang preprocessor to define the __STDCPP_FLOAT16_T__ (if _Float16 is available), __STDCPP_FLOAT32_T__, __STDCPP_FLOAT64_T__, and __STDCPP_FLOAT128_T__ (if _Float128 is available) macros in C++23 mode or later.