[libc++] Implement part of P2562R1: constexpr ranges::inplace_merge (#131947)

Drive-by changes:
- Consistently mark `std::__inplace_merge::__inplace_merge_impl`
`_LIBCPP_CONSTEXPR_SINCE_CXX26`.
- This function template is only called by other functions that becomes
constexpr since C++26, and it itself calls `std::__inplace_merge` that
is constexpr since C++26.
- Unblock related test coverage in constant evaluation for
`stable_partition`, `ranges::stable_sort`, `std::stable_sort`,
`std::stable_partition`, and `std::inplace_merge`.
This commit is contained in:
A. Jiang
2025-03-20 01:59:32 +08:00
committed by GitHub
parent 825460a772
commit 053a714add
9 changed files with 101 additions and 40 deletions

View File

@@ -1031,13 +1031,14 @@ namespace ranges {
template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,
class Proj = identity>
requires sortable<I, Comp, Proj>
I inplace_merge(I first, I middle, S last, Comp comp = {}, Proj proj = {}); // since C++20
constexpr I // constexpr since C++26
inplace_merge(I first, I middle, S last, Comp comp = {}, Proj proj = {}); // since C++20
template<bidirectional_range R, class Comp = ranges::less, class Proj = identity>
requires sortable<iterator_t<R>, Comp, Proj>
borrowed_iterator_t<R>
constexpr borrowed_iterator_t<R> // constexpr since C++26
inplace_merge(R&& r, iterator_t<R> middle, Comp comp = {},
Proj proj = {}); // since C++20
Proj proj = {}); // since C++20
template<permutable I, sentinel_for<I> S, class Proj = identity,
indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to>