|
31 | 31 | #include <__algorithm/move.h> |
32 | 32 | #include <__bit/bit_cast.h> |
33 | 33 | #include <__bit/bit_log2.h> |
34 | | -#include <__bit/countl.h> |
35 | 34 | #include <__config> |
36 | 35 | #include <__cstddef/size_t.h> |
37 | 36 | #include <__functional/identity.h> |
|
44 | 43 | #include <__numeric/partial_sum.h> |
45 | 44 | #include <__type_traits/decay.h> |
46 | 45 | #include <__type_traits/enable_if.h> |
| 46 | +#include <__type_traits/integral_constant.h> |
47 | 47 | #include <__type_traits/invoke.h> |
48 | 48 | #include <__type_traits/is_assignable.h> |
49 | 49 | #include <__type_traits/is_enum.h> |
50 | 50 | #include <__type_traits/is_integral.h> |
51 | 51 | #include <__type_traits/is_unsigned.h> |
52 | 52 | #include <__type_traits/make_unsigned.h> |
| 53 | +#include <__type_traits/void_t.h> |
| 54 | +#include <__utility/declval.h> |
53 | 55 | #include <__utility/forward.h> |
54 | 56 | #include <__utility/integer_sequence.h> |
55 | 57 | #include <__utility/move.h> |
@@ -379,6 +381,20 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __to_ordered_integral(_Floating __f) { |
379 | 381 | template <class _Enum, enable_if_t< is_enum<_Enum>::value, int> = 0> |
380 | 382 | _LIBCPP_HIDE_FROM_ABI constexpr auto __to_ordered_integral(_Enum __e) = delete; |
381 | 383 |
|
| 384 | +// `long double` varies significantly across platforms and compilers, making it practically |
| 385 | +// impossible to determine its actual bit width for conversion to an ordered integer. |
| 386 | +inline _LIBCPP_HIDE_FROM_ABI constexpr auto __to_ordered_integral(long double) = delete; |
| 387 | + |
| 388 | +template <class _Tp, class = void> |
| 389 | +struct __is_ordered_integer_representable : false_type {}; |
| 390 | + |
| 391 | +template <class _Tp> |
| 392 | +struct __is_ordered_integer_representable<_Tp, __void_t<decltype(__to_ordered_integral(std::declval<_Tp>()))>> |
| 393 | + : true_type {}; |
| 394 | + |
| 395 | +template <class _Tp> |
| 396 | +inline constexpr auto __is_ordered_integer_representable_v = __is_ordered_integer_representable<_Tp>::value; |
| 397 | + |
382 | 398 | struct __low_byte_fn { |
383 | 399 | template <class _Ip> |
384 | 400 | _LIBCPP_HIDE_FROM_ABI constexpr uint8_t operator()(_Ip __integer) const { |
|
0 commit comments