Skip to content

Commit 6e1d7fc

Browse files
committed
Use std::bool_constant
1 parent 2444202 commit 6e1d7fc

File tree

7 files changed

+12
-14
lines changed

7 files changed

+12
-14
lines changed

docs/Writing-a-sorter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ While type-specific sorters are, by their very nature, unable to generically han
368368

369369
## Stability
370370

371-
A sorting algorithm is said to be [stable][stability] if it preserves the relative order of *equivalent elements*. **cpp-sort** documents the stability of every sorter by giving them an `is_always_stable` type aliasing a boolean specialization of `std::integer_constant`. This information should be accessed via [`sorter_traits`][sorter-traits] or via the more specific [`is_always_stable`][is-always-stable] trait. The stability of a sorter is always either [`std::true_type` or `std::false_type`][std-integral-constant].
371+
A sorting algorithm is said to be [stable][stability] if it preserves the relative order of *equivalent elements*. **cpp-sort** documents the stability of every sorter by giving them an `is_always_stable` type aliasing a specialization of `std::bool_constant`. This information should be accessed via [`sorter_traits`][sorter-traits] or via the more specific [`is_always_stable`][is-always-stable] trait. The stability of a sorter is always either [`std::true_type` or `std::false_type`][std-integral-constant].
372372

373373
```cpp
374374
using stability = cppsort::is_always_stable<cppsort::tim_sorter>;

include/cpp-sort/adapters/verge_adapter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017-2023 Morwenn
2+
* Copyright (c) 2017-2025 Morwenn
33
* SPDX-License-Identifier: MIT
44
*/
55
#ifndef CPPSORT_ADAPTERS_VERGE_ADAPTER_H_
@@ -92,7 +92,7 @@ namespace cppsort
9292
// Sorter traits
9393

9494
using iterator_category = typename bidir_at_best_tag<Sorter>::type;
95-
using is_always_stable = std::integral_constant<bool, Stable>;
95+
using is_always_stable = std::bool_constant<Stable>;
9696
};
9797
}
9898

include/cpp-sort/detail/checkers.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016-2017 Morwenn
2+
* Copyright (c) 2016-2025 Morwenn
33
* SPDX-License-Identifier: MIT
44
*/
55
#ifndef CPPSORT_DETAIL_CHECKERS_H_
@@ -45,8 +45,7 @@ namespace detail
4545
template<typename... Sorters>
4646
struct check_is_always_stable_impl<true, Sorters...>
4747
{
48-
using is_always_stable = std::integral_constant<
49-
bool,
48+
using is_always_stable = std::bool_constant<
5049
all(typename sorter_traits<Sorters>::is_always_stable{}()...)
5150
>;
5251
};

include/cpp-sort/detail/move.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019-2022 Morwenn
2+
* Copyright (c) 2019-2025 Morwenn
33
* SPDX-License-Identifier: MIT
44
*/
55
#ifndef CPPSORT_DETAIL_MOVE_H_
@@ -101,7 +101,7 @@ namespace detail
101101
auto uninitialized_move(InputIterator first, InputIterator last, T* result, destruct_n<T>& destroyer)
102102
-> T*
103103
{
104-
using truth_type = std::integral_constant<bool,
104+
using truth_type = std::bool_constant<
105105
std::is_trivial<value_type_t<InputIterator>>::value &&
106106
std::is_trivial<T>::value
107107
>;

include/cpp-sort/detail/raw_checkers.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ namespace detail
7171
template<typename... Sorters>
7272
struct raw_check_is_always_stable_impl<true, Sorters...>
7373
{
74-
using is_always_stable = std::integral_constant<
75-
bool,
74+
using is_always_stable = std::bool_constant<
7675
all(typename Sorters::is_always_stable{}()...)
7776
>;
7877
};

include/cpp-sort/detail/ska_sort.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,15 +959,15 @@ namespace detail
959959

960960
template<>
961961
struct is_ska_sortable<float>:
962-
std::integral_constant<bool,
962+
std::bool_constant<
963963
sizeof(float) == sizeof(std::uint32_t) &&
964964
std::numeric_limits<float>::is_iec559
965965
>
966966
{};
967967

968968
template<>
969969
struct is_ska_sortable<double>:
970-
std::integral_constant<bool,
970+
std::bool_constant<
971971
sizeof(double) == sizeof(std::uint64_t) &&
972972
std::numeric_limits<double>::is_iec559
973973
>

include/cpp-sort/detail/vergesort.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015-2024 Morwenn
2+
* Copyright (c) 2015-2025 Morwenn
33
* SPDX-License-Identifier: MIT
44
*/
55
#ifndef CPPSORT_DETAIL_VERGESORT_H_
@@ -529,7 +529,7 @@ namespace verge
529529
verge::sort<Stable>(iterator_category_t<BidirectionalIterator>{},
530530
std::move(first), std::move(last), size,
531531
std::move(compare), std::move(projection),
532-
get_maybe_stable(std::integral_constant<bool, Stable>{}, std::move(fallback)));
532+
get_maybe_stable(std::bool_constant<Stable>{}, std::move(fallback)));
533533
}
534534
}}}
535535

0 commit comments

Comments
 (0)