Skip to content

Commit 15069f0

Browse files
committed
exclude-non-ieee-754
1 parent 88ef132 commit 15069f0

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

libcxx/include/__algorithm/radix_sort.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
#include <__type_traits/invoke.h>
4848
#include <__type_traits/is_assignable.h>
4949
#include <__type_traits/is_enum.h>
50-
#include <__type_traits/is_floating_point.h>
5150
#include <__type_traits/is_integral.h>
5251
#include <__type_traits/is_unsigned.h>
5352
#include <__type_traits/make_unsigned.h>
@@ -350,9 +349,9 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __to_ordered_integral(_Integral __n) {
350349
return __n;
351350
}
352351

353-
// An overload for floating-point numbers
352+
// An overload for IEEE 754 floating-point numbers
354353

355-
// From the IEEE 754 standard, we know that:
354+
// For the floats conforming to IEEE 754 (IEC 559) standard, we know that:
356355
// 1. The bit representation of positive floats directly reflects their order:
357356
// When comparing floats by magnitude, the number with the larger exponent is greater, and if the exponents are
358357
// equal, the one with the larger mantissa is greater.
@@ -369,7 +368,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __to_ordered_integral(_Integral __n) {
369368

370369
// Thus, in final integral representation, we have reversed the order for negative floats and made all negative floats
371370
// smaller than all positive numbers (by inverting the sign bit).
372-
template <class _Floating, enable_if_t< is_floating_point<_Floating>::value, int> = 0>
371+
template <class _Floating, enable_if_t< numeric_limits<_Floating>::is_iec559, int> = 0>
373372
_LIBCPP_HIDE_FROM_ABI constexpr auto __to_ordered_integral(_Floating __f) {
374373
using __integral_type = __unsigned_representation_for_t<_Floating>;
375374
constexpr auto __bit_count = std::numeric_limits<__integral_type>::digits;

libcxx/include/__algorithm/stable_sort.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@
2626
#include <__type_traits/desugars_to.h>
2727
#include <__type_traits/enable_if.h>
2828
#include <__type_traits/invoke.h>
29-
#include <__type_traits/is_arithmetic.h>
3029
#include <__type_traits/is_constant_evaluated.h>
30+
#include <__type_traits/is_integral.h>
3131
#include <__type_traits/is_same.h>
3232
#include <__type_traits/is_trivially_assignable.h>
3333
#include <__utility/move.h>
3434
#include <__utility/pair.h>
35+
#include <limits>
3536

3637
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3738
# pragma GCC system_header
@@ -249,7 +250,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void __stable_sort(
249250
#if _LIBCPP_STD_VER >= 17
250251
constexpr auto __default_comp = __desugars_to_v<__less_tag, _Compare, value_type, value_type >;
251252
constexpr auto __arithmetic_value =
252-
is_arithmetic_v<value_type > && is_same_v< value_type&, __iter_reference<_RandomAccessIterator>>;
253+
(is_integral_v<value_type > || numeric_limits<value_type>::is_iec559) &&
254+
is_same_v< value_type&, __iter_reference<_RandomAccessIterator>>;
253255
if constexpr (__default_comp && __arithmetic_value) {
254256
if (__len <= __buff_size && __len >= static_cast<difference_type>(std::__radix_sort_min_bound<value_type>()) &&
255257
__len <= static_cast<difference_type>(std::__radix_sort_max_bound<value_type>())) {

0 commit comments

Comments
 (0)