@@ -194,25 +194,25 @@ struct __stable_sort_switch {
194194 static const unsigned value = 128 * is_trivially_copy_assignable<_Tp>::value;
195195};
196196
197- template <class _Tp , class = void >
198- struct __radix_sort_min_switch {
199- static const unsigned value = (1 << 10 );
200- };
197+ template <class _Tp >
198+ constexpr unsigned __radix_sort_min_bound () {
199+ static_assert (is_integral<_Tp>::value);
200+ if constexpr (sizeof (_Tp) == 1 ) {
201+ return 1 << 8 ;
202+ }
201203
202- template <class _Int8 >
203- struct __radix_sort_min_switch <_Int8, __enable_if_t <is_integral<_Int8>::value && sizeof (_Int8) == 1 > > {
204- static const unsigned value = (1 << 8 );
205- };
204+ return 1 << 10 ;
205+ }
206206
207- template <class _Tp , class = void >
208- struct __radix_sort_max_switch {
209- static const unsigned value = (1 << 16 );
210- };
207+ template <class _Tp >
208+ constexpr unsigned __radix_sort_max_bound () {
209+ static_assert (is_integral<_Tp>::value);
210+ if constexpr (sizeof (_Tp) == 8 ) {
211+ return 1 << 15 ;
212+ }
211213
212- template <class _Int64 >
213- struct __radix_sort_max_switch <_Int64, __enable_if_t <is_integral<_Int64>::value && sizeof (_Int64) == 8 > > {
214- static const unsigned value = (1 << 15 );
215- };
214+ return 1 << 16 ;
215+ }
216216
217217template <class _AlgPolicy , class _Compare , class _RandomAccessIterator >
218218void __stable_sort (_RandomAccessIterator __first,
@@ -241,8 +241,8 @@ void __stable_sort(_RandomAccessIterator __first,
241241 constexpr auto __integral_value = is_integral_v<value_type >;
242242 constexpr auto __allowed_radix_sort = __default_comp && __integral_value;
243243 if constexpr (__allowed_radix_sort) {
244- if (__len <= __buff_size && __len >= static_cast <difference_type>(__radix_sort_min_switch <value_type>::value ) &&
245- __len <= static_cast <difference_type>(__radix_sort_max_switch <value_type>::value )) {
244+ if (__len <= __buff_size && __len >= static_cast <difference_type>(__radix_sort_min_bound <value_type>() ) &&
245+ __len <= static_cast <difference_type>(__radix_sort_max_bound <value_type>() )) {
246246 std::__radix_sort (__first, __last, __buff);
247247 return ;
248248 }
0 commit comments