]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: add constexpr inplace_merge
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Fri, 14 Mar 2025 14:47:10 +0000 (15:47 +0100)
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Thu, 27 Mar 2025 12:47:30 +0000 (13:47 +0100)
commit698ef4b29d875b9ab8903e95633f1473a29c217b
treec72ef3745a50e56bfabd4b724fa32f1703bfc522
parent8e99bd447c459d8f298a70355a89122683d7b149
libstdc++: add constexpr inplace_merge

This commit adds support for constexpr inplace_merge, added by P2562R1
for C++26. The implementation strategy is the same as for constexpr
stable_sort: use if consteval to detect if we're in constant evaluation,
and dispatch to a suitable path (same one as freestanding).

libstdc++-v3/ChangeLog:

* include/bits/algorithmfwd.h (inplace_merge): Mark it as
constexpr for C++26.
* include/bits/ranges_algo.h (__inplace_merge_fn): Likewise.
* include/bits/stl_algo.h (inplace_merge): Mark it as constexpr;
during constant evaluation, dispatch to the non-allocating
codepath.
* testsuite/25_algorithms/headers/algorithm/synopsis.cc
(inplace_merge): Add constexpr.
* testsuite/25_algorithms/inplace_merge/constexpr.cc: New test.
libstdc++-v3/include/bits/algorithmfwd.h
libstdc++-v3/include/bits/ranges_algo.h
libstdc++-v3/include/bits/stl_algo.h
libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc
libstdc++-v3/testsuite/25_algorithms/inplace_merge/constexpr.cc [new file with mode: 0644]