@@ -195,25 +195,25 @@ struct __stable_sort_switch {
195195 static const unsigned value = 128 * is_trivially_copy_assignable<_Tp>::value;
196196};
197197
198- template <class _Tp , class = void >
199- struct __radix_sort_min_switch {
200- static const unsigned value = (1 << 10 );
201- };
198+ template <class _Tp >
199+ constexpr unsigned __radix_sort_min_bound () {
200+ static_assert (is_integral<_Tp>::value);
201+ if constexpr (sizeof (_Tp) == 1 ) {
202+ return 1 << 8 ;
203+ }
202204
203- template <class _Int8 >
204- struct __radix_sort_min_switch <_Int8, __enable_if_t <is_integral<_Int8>::value && sizeof (_Int8) == 1 > > {
205- static const unsigned value = (1 << 8 );
206- };
205+ return 1 << 10 ;
206+ }
207207
208- template <class _Tp , class = void >
209- struct __radix_sort_max_switch {
210- static const unsigned value = (1 << 16 );
211- };
208+ template <class _Tp >
209+ constexpr unsigned __radix_sort_max_bound () {
210+ static_assert (is_integral<_Tp>::value);
211+ if constexpr (sizeof (_Tp) == 8 ) {
212+ return 1 << 15 ;
213+ }
212214
213- template <class _Int64 >
214- struct __radix_sort_max_switch <_Int64, __enable_if_t <is_integral<_Int64>::value && sizeof (_Int64) == 8 > > {
215- static const unsigned value = (1 << 15 );
216- };
215+ return 1 << 16 ;
216+ }
217217
218218template <class _AlgPolicy , class _Compare , class _RandomAccessIterator >
219219void __stable_sort (_RandomAccessIterator __first,
@@ -242,8 +242,8 @@ void __stable_sort(_RandomAccessIterator __first,
242242 constexpr auto __integral_value = is_integral_v<value_type >;
243243 constexpr auto __allowed_radix_sort = __default_comp && __integral_value;
244244 if constexpr (__allowed_radix_sort) {
245- if (__len <= __buff_size && __len >= static_cast <difference_type>(__radix_sort_min_switch <value_type>::value ) &&
246- __len <= static_cast <difference_type>(__radix_sort_max_switch <value_type>::value )) {
245+ if (__len <= __buff_size && __len >= static_cast <difference_type>(__radix_sort_min_bound <value_type>() ) &&
246+ __len <= static_cast <difference_type>(__radix_sort_max_bound <value_type>() )) {
247247 std::__radix_sort (__first, __last, __buff);
248248 return ;
249249 }
0 commit comments