Skip to content

Commit

Permalink
stable sort関係 : C++26でのconstexpr対応 (close #1182)
Browse files Browse the repository at this point in the history
  • Loading branch information
faithandbrave committed Aug 2, 2024
1 parent b9076ff commit 3af3684
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 6 deletions.
17 changes: 15 additions & 2 deletions reference/algorithm/inplace_merge.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,23 @@ namespace std {
void inplace_merge(BidirectionalIterator first,
BidirectionalIterator middle,
BidirectionalIterator last); // (1) C++03
template <class BidirectionalIterator>
constexpr
void inplace_merge(BidirectionalIterator first,
BidirectionalIterator middle,
BidirectionalIterator last); // (1) C++26

template <class BidirectionalIterator, class Compare>
void inplace_merge(BidirectionalIterator first,
BidirectionalIterator middle,
BidirectionalIterator last,
Compare comp); // (2) C++03
template <class BidirectionalIterator, class Compare>
constexpr
void inplace_merge(BidirectionalIterator first,
BidirectionalIterator middle,
BidirectionalIterator last,
Compare comp); // (2) C++26

template <class ExecutionPolicy, class BidirectionalIterator>
void inplace_merge(ExecutionPolicy&& exec,
Expand Down Expand Up @@ -94,7 +105,9 @@ int main()
```

## 実装例
- [inplace_merge を読んでみた](http://www.kmonos.net/wlog/115.html#_2300101215)

- [`inplace_merge` を読んでみた](http://www.kmonos.net/wlog/115.html#_2300101215)


## 参照
- [P2562R1 `constexpr` Stable Sorting](https://open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2562r1.pdf)
- C++26から`constexpr`に対応した
26 changes: 23 additions & 3 deletions reference/algorithm/ranges_inplace_merge.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ namespace std::ranges {
S last,
Comp comp = {},
Proj proj = {}); // (1) C++20
template <bidirectional_iterator I,
sentinel_for<I> S,
class Comp = ranges::less,
class Proj = identity>
requires sortable<I, Comp, Proj>
constexpr I
inplace_merge(I first,
I middle,
S last,
Comp comp = {},
Proj proj = {}); // (1) C++26

template <bidirectional_range R,
class Comp = ranges::less,
Expand All @@ -27,6 +38,15 @@ namespace std::ranges {
iterator_t<R> middle,
Comp comp = {},
Proj proj = {}); // (2) C++20
template <bidirectional_range R,
class Comp = ranges::less,
class Proj = identity>
requires sortable<iterator_t<R>, Comp, Proj>
constexpr borrowed_iterator_t<R>
inplace_merge(R&& r,
iterator_t<R> middle,
Comp comp = {},
Proj proj = {}); // (2) C++26
}
```
* bidirectional_iterator[link /reference/iterator/bidirectional_iterator.md]
Expand Down Expand Up @@ -98,7 +118,7 @@ int main()
```

## 実装例
- [inplace_merge を読んでみた](http://www.kmonos.net/wlog/115.html#_2300101215)
- [`inplace_merge` を読んでみた](http://www.kmonos.net/wlog/115.html#_2300101215)

## バージョン
### 言語
Expand All @@ -112,5 +132,5 @@ int main()

## 参照
- [N4861 25 Algorithms library](https://timsong-cpp.github.io/cppwp/n4861/algorithms)


- [P2562R1 `constexpr` Stable Sorting](https://open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2562r1.pdf)
- C++26から`constexpr`に対応した
20 changes: 20 additions & 0 deletions reference/algorithm/ranges_stable_partition.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ namespace std::ranges {
S last,
Pred pred,
Proj proj = {}); // (1) C++20
template <bidirectional_iterator I,
sentinel_for<I> S,
class Proj = identity,
indirect_unary_predicate<projected<I, Proj>> Pred>
requires permutable<I>
constexpr subrange<I>
stable_partition(I first,
S last,
Pred pred,
Proj proj = {}); // (1) C++26

template <bidirectional_range R,
class Proj = identity,
Expand All @@ -25,6 +35,14 @@ namespace std::ranges {
stable_partition(R&& r,
Pred pred,
Proj proj = {}); // (2) C++20
template <bidirectional_range R,
class Proj = identity,
indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
requires permutable<iterator_t<R>>
constexpr borrowed_subrange_t<R>
stable_partition(R&& r,
Pred pred,
Proj proj = {}); // (2) C++26
}
```
* bidirectional_iterator[link /reference/iterator/bidirectional_iterator.md]
Expand Down Expand Up @@ -106,3 +124,5 @@ int main()

## 参照
- [N4861 25 Algorithms library](https://timsong-cpp.github.io/cppwp/n4861/algorithms)
- [P2562R1 `constexpr` Stable Sorting](https://open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2562r1.pdf)
- C++26から`constexpr`に対応した
20 changes: 20 additions & 0 deletions reference/algorithm/ranges_stable_sort.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ namespace std::ranges {
S last,
Comp comp = {},
Proj proj = {}); // (1) C++20
template <random_access_iterator I,
sentinel_for<I> S,
class Comp = ranges::less,
class Proj = identity>
requires sortable<I, Comp, Proj>
constexpr I
stable_sort(I first,
S last,
Comp comp = {},
Proj proj = {}); // (1) C++26

template <random_access_range R,
class Comp = ranges::less,
Expand All @@ -25,6 +35,14 @@ namespace std::ranges {
stable_sort(R&& r,
Comp comp = {},
Proj proj = {}); // (2) C++20
template <random_access_range R,
class Comp = ranges::less,
class Proj = identity>
requires sortable<iterator_t<R>, Comp, Proj>
constexpr borrowed_iterator_t<R>
stable_sort(R&& r,
Comp comp = {},
Proj proj = {}); // (2) C++26
}
```
* random_access_iterator[link /reference/iterator/random_access_iterator.md]
Expand Down Expand Up @@ -96,3 +114,5 @@ int main()

## 参照
- [N4861 25 Algorithms library](https://timsong-cpp.github.io/cppwp/n4861/algorithms)
- [P2562R1 `constexpr` Stable Sorting](https://open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2562r1.pdf)
- C++26から`constexpr`に対応した
7 changes: 7 additions & 0 deletions reference/algorithm/stable_partition.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ namespace std {
stable_partition(BidirectionalIterator first,
BidirectionalIterator last,
Predicate pred); // (1) C++03
template<class BidirectionalIterator, class Predicate>
constexpr BidirectionalIterator
stable_partition(BidirectionalIterator first,
BidirectionalIterator last,
Predicate pred); // (1) C++26

template <class ExecutionPolicy, class BidirectionalIterator, class Predicate>
BidirectionalIterator
Expand Down Expand Up @@ -81,3 +86,5 @@ int main()
## 参照
- [LWG Issue 2150. Unclear specification of `find_end`](http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2150)
- [P0574R1 Algorithm Complexity Constraints and Parallel Overloads](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0574r1.html)
- [P2562R1 `constexpr` Stable Sorting](https://open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2562r1.pdf)
- C++26から`constexpr`に対応した
15 changes: 14 additions & 1 deletion reference/algorithm/stable_sort.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@
namespace std {
template <class RandomAccessIterator>
void stable_sort(RandomAccessIterator first,
RandomAccessIterator last); // (1) C++03
RandomAccessIterator last); // (1) C++03
template <class RandomAccessIterator>
constexpr
void stable_sort(RandomAccessIterator first,
RandomAccessIterator last); // (1) C++26

template <class RandomAccessIterator, class Compare>
void stable_sort(RandomAccessIterator first,
RandomAccessIterator last,
Compare comp); // (2) C++03
template <class RandomAccessIterator, class Compare>
constexpr
void stable_sort(RandomAccessIterator first,
RandomAccessIterator last,
Compare comp); // (2) C++26

template<class ExecutionPolicy, class RandomAccessIterator>
void stable_sort(ExecutionPolicy&& exec,
Expand Down Expand Up @@ -82,3 +91,7 @@ int main()
5
```


## 参照
- [P2562R1 `constexpr` Stable Sorting](https://open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2562r1.pdf)
- C++26から`constexpr`に対応した

0 comments on commit 3af3684

Please sign in to comment.