Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2226672/?format=api
{ "id": 2226672, "url": "http://patchwork.ozlabs.org/api/patches/2226672/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/bmm.hhuo2dtkd4.gcc.gcc-TEST.peppe.44.1.1@forge-stage.sourceware.org/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/projects/17/?format=api", "name": "GNU Compiler Collection", "link_name": "gcc", "list_id": "gcc-patches.gcc.gnu.org", "list_email": "gcc-patches@gcc.gnu.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<bmm.hhuo2dtkd4.gcc.gcc-TEST.peppe.44.1.1@forge-stage.sourceware.org>", "list_archive_url": null, "date": "2026-04-22T18:10:41", "name": "[v1,1/2] libstdc++: add constexpr inplace_merge", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "b07fb04a61dd6e5eed5d00c7f4ecc259fc4ad249", "submitter": { "id": 93222, "url": "http://patchwork.ozlabs.org/api/people/93222/?format=api", "name": "peppe via Sourceware Forge", "email": "forge-bot+peppe@forge-stage.sourceware.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/bmm.hhuo2dtkd4.gcc.gcc-TEST.peppe.44.1.1@forge-stage.sourceware.org/mbox/", "series": [ { "id": 501068, "url": "http://patchwork.ozlabs.org/api/series/501068/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=501068", "date": "2026-04-22T18:10:42", "name": "WIP: more_constexpr_stable_algorithms", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/501068/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2226672/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2226672/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Delivered-To": [ "patchwork-incoming@legolas.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Authentication-Results": [ "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)", "sourceware.org; dmarc=none (p=none dis=none)\n header.from=forge-stage.sourceware.org", "sourceware.org;\n spf=pass smtp.mailfrom=forge-stage.sourceware.org", "server2.sourceware.org;\n arc=none smtp.remote-ip=38.145.34.39" ], "Received": [ "from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g16tz2KGnz1yD5\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 23 Apr 2026 04:19:23 +1000 (AEST)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 5112951A4310\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 18:19:21 +0000 (GMT)", "from forge-stage.sourceware.org (vm08.sourceware.org [38.145.34.39])\n by sourceware.org (Postfix) with ESMTPS id 6CE754BBC0C5\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 18:11:37 +0000 (GMT)", "from forge-stage.sourceware.org (localhost [IPv6:::1])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256)\n (No client certificate requested)\n by forge-stage.sourceware.org (Postfix) with ESMTPS id 415A94340A\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 18:11:37 +0000 (UTC)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 5112951A4310", "OpenDKIM Filter v2.11.0 sourceware.org 6CE754BBC0C5" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 6CE754BBC0C5", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 6CE754BBC0C5", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776881497; cv=none;\n b=SDJLAwPpLOs2xnWhRveVD0KEpIEoHy3oydsX/9t7/d99VFoD6GiK0YJkuN4kCv0Q1gbv1vM5Z689Pc5VB0KNWIoX4onu1pCD5/r+uCp98WcEr9DoQM8Is9KOE0z7PKw5+F42vFgJOk21IVEMeNjqYQWGcYCtIWTs3Kt0XJcvjpI=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776881497; c=relaxed/simple;\n bh=PNqgtaIGKLHt6nO/ItrJJpyubgZPVqTl67uwL0Abdew=;\n h=From:Date:Subject:To:Message-ID;\n b=Ulk7v5WHhDpI/hI0OaFIk8aLdWHR3Jw2zRGmOX5Iy12Seyt0K8B5hJ+UsgSM/GyabizJiQXb0NJtw+a3zXtWbyZB7jv3nnJhEqFIhjm7nkFCpEihxnKFTz0Qk0PGZv30KtqmwcuirjNOvYI92mC096LSyCJz++NYj1v9WTa3KWg=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "From": "peppe via Sourceware Forge <forge-bot+peppe@forge-stage.sourceware.org>", "Date": "Wed, 22 Apr 2026 18:10:41 +0000", "Subject": "[PATCH v1 1/2] libstdc++: add constexpr inplace_merge", "To": "gcc-patches mailing list <gcc-patches@gcc.gnu.org>", "Message-ID": "\n <bmm.hhuo2dtkd4.gcc.gcc-TEST.peppe.44.1.1@forge-stage.sourceware.org>", "X-Mailer": "batrachomyomachia", "X-Requested-Reviewer": "redi", "X-Pull-Request-Organization": "gcc", "X-Pull-Request-Repository": "gcc-TEST", "X-Pull-Request": "https://forge.sourceware.org/gcc/gcc-TEST/pulls/44", "References": "\n <bmm.hhuo2dtkd4.gcc.gcc-TEST.peppe.44.1.0@forge-stage.sourceware.org>", "In-Reply-To": "\n <bmm.hhuo2dtkd4.gcc.gcc-TEST.peppe.44.1.0@forge-stage.sourceware.org>", "X-Patch-URL": "\n https://forge.sourceware.org/peppe/gcc-TEST/commit/5989657326b5a977257f8139ae024dd18e27cb01", "X-BeenThere": "gcc-patches@gcc.gnu.org", "X-Mailman-Version": "2.1.30", "Precedence": "list", "List-Id": "Gcc-patches mailing list <gcc-patches.gcc.gnu.org>", "List-Unsubscribe": "<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>", "List-Archive": "<https://gcc.gnu.org/pipermail/gcc-patches/>", "List-Post": "<mailto:gcc-patches@gcc.gnu.org>", "List-Help": "<mailto:gcc-patches-request@gcc.gnu.org?subject=help>", "List-Subscribe": "<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>", "Reply-To": "gcc-patches mailing list <gcc-patches@gcc.gnu.org>,\n peppe@noreply.localhost", "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org" }, "content": "From: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>\n\nThis commit adds support for constexpr inplace_merge, added by P2562R1\nfor C++26. The implementation strategy is the same as for constexpr\nstable_sort: use if consteval to detect if we're in constant evaluation,\nand dispatch to a suitable path (same one as freestanding).\n\nlibstdc++-v3/ChangeLog:\n\n\t* include/bits/algorithmfwd.h (inplace_merge): Mark it as\n\tconstexpr for C++26.\n\t* include/bits/ranges_algo.h (__inplace_merge_fn): Likewise.\n\t* include/bits/stl_algo.h (inplace_merge): Mark it as constexpr;\n\tduring constant evaluation, dispatch to the non-allocating\n\tcodepath.\n\t* testsuite/25_algorithms/headers/algorithm/synopsis.cc\n\t(inplace_merge): Add constexpr.\n\t* testsuite/25_algorithms/inplace_merge/constexpr.cc: New test.\n---\n libstdc++-v3/include/bits/algorithmfwd.h | 2 +\n libstdc++-v3/include/bits/ranges_algo.h | 2 +\n libstdc++-v3/include/bits/stl_algo.h | 9 +++\n .../headers/algorithm/synopsis.cc | 2 +\n .../25_algorithms/inplace_merge/constexpr.cc | 72 +++++++++++++++++++\n 5 files changed, 87 insertions(+)\n create mode 100644 libstdc++-v3/testsuite/25_algorithms/inplace_merge/constexpr.cc", "diff": "diff --git a/libstdc++-v3/include/bits/algorithmfwd.h b/libstdc++-v3/include/bits/algorithmfwd.h\nindex 3e81bca0348a..05894b580028 100644\n--- a/libstdc++-v3/include/bits/algorithmfwd.h\n+++ b/libstdc++-v3/include/bits/algorithmfwd.h\n@@ -315,10 +315,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n includes(_IIter1, _IIter1, _IIter2, _IIter2, _Compare);\n \n template<typename _BIter>\n+ _GLIBCXX26_CONSTEXPR\n void\n inplace_merge(_BIter, _BIter, _BIter);\n \n template<typename _BIter, typename _Compare>\n+ _GLIBCXX26_CONSTEXPR\n void\n inplace_merge(_BIter, _BIter, _BIter, _Compare);\n \ndiff --git a/libstdc++-v3/include/bits/ranges_algo.h b/libstdc++-v3/include/bits/ranges_algo.h\nindex d3644a83f802..2814d90061cc 100644\n--- a/libstdc++-v3/include/bits/ranges_algo.h\n+++ b/libstdc++-v3/include/bits/ranges_algo.h\n@@ -2598,6 +2598,7 @@ namespace ranges\n \t typename _Comp = ranges::less,\n \t typename _Proj = identity>\n requires sortable<_Iter, _Comp, _Proj>\n+ _GLIBCXX26_CONSTEXPR\n _Iter\n operator()(_Iter __first, _Iter __middle, _Sent __last,\n \t\t _Comp __comp = {}, _Proj __proj = {}) const\n@@ -2611,6 +2612,7 @@ namespace ranges\n template<bidirectional_range _Range,\n \t typename _Comp = ranges::less, typename _Proj = identity>\n requires sortable<iterator_t<_Range>, _Comp, _Proj>\n+ _GLIBCXX26_CONSTEXPR\n borrowed_iterator_t<_Range>\n operator()(_Range&& __r, iterator_t<_Range> __middle,\n \t\t _Comp __comp = {}, _Proj __proj = {}) const\ndiff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h\nindex c3fea76014cb..bb7dbfbd8e04 100644\n--- a/libstdc++-v3/include/bits/stl_algo.h\n+++ b/libstdc++-v3/include/bits/stl_algo.h\n@@ -2465,6 +2465,7 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)\n }\n \n template<typename _BidirectionalIterator, typename _Compare>\n+ _GLIBCXX26_CONSTEXPR\n void\n __inplace_merge(_BidirectionalIterator __first,\n \t\t _BidirectionalIterator __middle,\n@@ -2483,6 +2484,12 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)\n const _DistanceType __len2 = std::distance(__middle, __last);\n \n #if _GLIBCXX_HOSTED\n+# if __glibcxx_constexpr_algorithms >= 202306L // >= C++26\n+ if consteval {\n+\treturn std::__merge_without_buffer\n+\t (__first, __middle, __last, __len1, __len2, __comp);\n+ }\n+# endif\n typedef _Temporary_buffer<_BidirectionalIterator, _ValueType> _TmpBuf;\n // __merge_adaptive will use a buffer for the smaller of\n // [first,middle) and [middle,last).\n@@ -2523,6 +2530,7 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)\n * distance(__first,__last).\n */\n template<typename _BidirectionalIterator>\n+ _GLIBCXX26_CONSTEXPR\n inline void\n inplace_merge(_BidirectionalIterator __first,\n \t\t _BidirectionalIterator __middle,\n@@ -2564,6 +2572,7 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)\n * the function used for the initial sort.\n */\n template<typename _BidirectionalIterator, typename _Compare>\n+ _GLIBCXX26_CONSTEXPR\n inline void\n inplace_merge(_BidirectionalIterator __first,\n \t\t _BidirectionalIterator __middle,\ndiff --git a/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc b/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc\nindex 5000b18fc42b..8d5c1fb7ac73 100644\n--- a/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc\n+++ b/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc\n@@ -458,10 +458,12 @@ namespace std\n merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare);\n \n template<typename _BIter>\n+ _GLIBCXX26_CONSTEXPR\n void\n inplace_merge(_BIter, _BIter, _BIter);\n \n template<typename _BIter, typename _Compare>\n+ _GLIBCXX26_CONSTEXPR\n void\n inplace_merge(_BIter, _BIter, _BIter, _Compare);\n \ndiff --git a/libstdc++-v3/testsuite/25_algorithms/inplace_merge/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/constexpr.cc\nnew file mode 100644\nindex 000000000000..0bc4ed463d0f\n--- /dev/null\n+++ b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/constexpr.cc\n@@ -0,0 +1,72 @@\n+// { dg-do compile { target c++26 } }\n+\n+#include <algorithm>\n+#include <array>\n+#include <functional>\n+#include <utility>\n+\n+// returns a pair [array, index of partitioning point]\n+constexpr auto\n+create_array()\n+{\n+ return std::make_pair(\n+ std::to_array({0, 2, 2, 2, 4, 6, 1, 2, 3, 3, 4, 4, 5}),\n+ 6);\n+}\n+\n+constexpr bool\n+test01()\n+{\n+ auto [ar, index] = create_array();\n+ std::inplace_merge(ar.begin(), ar.begin() + index, ar.end());\n+ return std::is_sorted(ar.begin(), ar.end());\n+}\n+\n+static_assert(test01());\n+\n+constexpr bool\n+test02()\n+{\n+ auto [ar, index] = create_array();\n+ auto index_it = ar.begin() + index;\n+ std::reverse(ar.begin(), index_it);\n+ std::reverse(index_it, ar.end());\n+ std::inplace_merge(ar.begin(), index_it, ar.end(), std::greater<>());\n+ return std::is_sorted(ar.begin(), ar.end(), std::greater<>());\n+}\n+\n+static_assert(test02());\n+\n+constexpr bool\n+test03()\n+{\n+ auto [ar, index] = create_array();\n+ std::ranges::inplace_merge(ar, ar.begin() + index);\n+ return std::ranges::is_sorted(ar);\n+}\n+\n+static_assert(test03());\n+\n+constexpr bool\n+test04()\n+{\n+ auto [ar, index] = create_array();\n+ auto index_it = ar.begin() + index;\n+ std::ranges::reverse(ar.begin(), index_it);\n+ std::ranges::reverse(index_it, ar.end());\n+ std::ranges::inplace_merge(ar, index_it, std::ranges::greater());\n+ return std::ranges::is_sorted(ar, std::ranges::greater());\n+}\n+\n+static_assert(test04());\n+\n+constexpr bool\n+test05()\n+{\n+ auto [ar, index] = create_array();\n+ auto proj = [](int i) { return -i; };\n+ std::ranges::inplace_merge(ar, ar.begin() + index, std::ranges::greater(), proj);\n+ return std::ranges::is_sorted(ar, std::ranges::greater(), proj);\n+}\n+\n+static_assert(test05());\n", "prefixes": [ "v1", "1/2" ] }