{"id":2219834,"url":"http://patchwork.ozlabs.org/api/patches/2219834/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/20260404170122.2928689-2-ivan.lazaric1@gmail.com/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/projects/17/?format=json","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":"<20260404170122.2928689-2-ivan.lazaric1@gmail.com>","list_archive_url":null,"date":"2026-04-04T17:01:23","name":"libstdc++: Implement P1789R3: structured bindings for std::integer_sequence","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"e7e6ee832adeca5507c5748fa18f5373c9012e33","submitter":{"id":92628,"url":"http://patchwork.ozlabs.org/api/people/92628/?format=json","name":"Ivan Lazaric","email":"ivan.lazaric1@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/20260404170122.2928689-2-ivan.lazaric1@gmail.com/mbox/","series":[{"id":498741,"url":"http://patchwork.ozlabs.org/api/series/498741/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=498741","date":"2026-04-04T17:01:23","name":"libstdc++: Implement P1789R3: structured bindings for std::integer_sequence","version":1,"mbox":"http://patchwork.ozlabs.org/series/498741/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2219834/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2219834/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\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=KNRFuoiI;\n\tdkim-atps=neutral","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;\n\tdkim=pass (2048-bit key,\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=KNRFuoiI","sourceware.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com","sourceware.org; spf=pass smtp.mailfrom=gmail.com","server2.sourceware.org;\n arc=none smtp.remote-ip=209.85.218.42"],"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 4fp23Q1QTQz1yG2\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 05 Apr 2026 03:03:12 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id BFDCF4BA23C3\n\tfor <incoming@patchwork.ozlabs.org>; Sat,  4 Apr 2026 17:03:10 +0000 (GMT)","from mail-ej1-f42.google.com (mail-ej1-f42.google.com\n [209.85.218.42])\n by sourceware.org (Postfix) with ESMTPS id 3AD884BA2E2B\n for <gcc-patches@gcc.gnu.org>; Sat,  4 Apr 2026 17:02:26 +0000 (GMT)","by mail-ej1-f42.google.com with SMTP id\n a640c23a62f3a-b9c1da7ac63so475598266b.0\n for <gcc-patches@gcc.gnu.org>; Sat, 04 Apr 2026 10:02:26 -0700 (PDT)","from ilazaric-gram.arnhem.chello.nl\n (2001-1c00-4c85-8400-bc45-0a59-504a-1b6d.cable.dynamic.v6.ziggo.nl.\n [2001:1c00:4c85:8400:bc45:a59:504a:1b6d])\n by smtp.gmail.com with ESMTPSA id\n 4fb4d7f45d1cf-66e033a74e8sm2497413a12.16.2026.04.04.10.02.23\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Sat, 04 Apr 2026 10:02:24 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org BFDCF4BA23C3","OpenDKIM Filter v2.11.0 sourceware.org 3AD884BA2E2B"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 3AD884BA2E2B","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 3AD884BA2E2B","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775322146; cv=none;\n b=f7X714rOLmBHxRH9GmgXHOn0ZWUg/b0KC57RTJj5hJZnmAJx82y0Vx7mEGzyX9pT6HLkWRNd9ee+hyiD5A2RafdWpWBiHaO3lzWDTEa+MOXWtz6UczcwizC1sk5mo6fTuxDbR+4eRMpT8kgBfxUSto8a/sJ2o2OGo8Qab+SkOgg=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1775322146; c=relaxed/simple;\n bh=nOE0bDUjXiXQEyawqm7xHg8PoKA3HTNP2QEfAHRatNw=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=CX5bRVSP5pzLy4uRBR2qnPik/Sm/+kW2n40S/dFSroMaDjQSKcuiXBxOtSYnM35u4IL5Lcexf5ki/DZoGd0azRyMtH1fdqbAMWTJ/+M73jp4wzaqgBbWtl2R3Uh9qT/pmsk4wyMXcEW8tkaW4tmFjvfZDA68rKFgl5kgggjc8hk=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1775322145; x=1775926945; darn=gcc.gnu.org;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:from:to:cc:subject:date:message-id:reply-to;\n bh=RXQ4CWHhyq3OayvDBRhh+dO5fFrrVPoMciUk7FZU5fw=;\n b=KNRFuoiIqxKqOXEEXKle/nxagyKIGtXUvd0Ay60Bd2r0dVAMPwSDgikU6Vaxy7DdZk\n LvKUVLNVqKCxcpGn2l19urHfrRjjoeqQJ78hvmjaXTBKV4DzBm14ZPv7CZLtNnpZoaEC\n Q0QopjSU+NTXyZfy0vu4JiZd8peCc0xtJZKRZ7SJACB2ryh5scDiIQJnDqm7/PWH+hwE\n PLwc4wqOdqLSZpg6qNTmifVV/jyz9zIH7bc7jTdCxyhuq+MHzlbJUAL7pU21giGTX0ye\n 8cxh7EL58f+ilDhP+kNK4D4r2gveyzS0G3nWziHwQfyVm9ndAR+BLPX732DFZYZ6Dmkh\n ImTw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775322145; x=1775926945;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=RXQ4CWHhyq3OayvDBRhh+dO5fFrrVPoMciUk7FZU5fw=;\n b=V0hPyrHmz4ghqTPjfdNMWsEiLiZX3fAwgWpYRSSGlhqYv4mmZkKOkAR5C0xrvKIgpg\n WFTYjPc634XgbMOZoiOTSqGz7JlrhqjVqe2asmv1/3T1hh3sd+b/xk8FPufXXDdK2AHc\n iZP35pwoFMlJazL+OlTN7z47ze1fCzxPjSI87cwuvwjpIl4tktvFI/Ek6pmsR3LUa8zQ\n 6/wtMcjJshnroCVYAMsJ5o0v7z58mL5TTTq/1LvfndQh2Zt/LEqEOsIRPIMlf15Stkfi\n JZbVXMluCXta2skRdAZNufxhLT/eMQRN06U1oNeJn0nAPuexAGNrLDuHtyqo0hHBKK4s\n qm9w==","X-Forwarded-Encrypted":"i=1;\n AJvYcCWGb/44qEPGUPJKwpqz3QXRquroQVu59xWUMko9NUbs/tyalyPRcu7UcXCyYjToqX30E+ZmEAMFmxp7TQ==@gcc.gnu.org","X-Gm-Message-State":"AOJu0YwZlvH2/Aw0w4CmeTXMqZ26A3qn1WBap5Zf1E51ZnoOsIhZgkWT\n U3Bvbu5TP5H280Fv44fxqPLSZKbtBxUfanxi+e66hdoohRt65ZGjkd+1","X-Gm-Gg":"AeBDieuhXkVExz2Rk60+C/90yEWXT9iI4SivsCc6lZ2sVUZuRQwaHwwmFro1yg7wqIa\n MjKTfwYtaPDx79ilUts4uFZXxQlZCMm6UX7dJ9Abh39UM6S+Yii/ploFHkPFcp3L+NFQpfi3FJT\n d2A9fm2SMLeAJPUJj+YYHK+mqFUqZ6mKTgjojIp6iYsN+S3eMErRx4acD8URTl1LUcb5pZM/0ki\n 4ffMcIJNn1VqH5xuoqdH62kOXE8hYNZ3LYNOykzfRNv+j2snMiFxBokhqQwA2WT5L8OecHITSW1\n Gb7r2tWQTNgMb0Ai6fd5kfQWxsbhWIS11KzT9aJW8Gb52LJ+Y4XaeUKqg9w4pGuthoHZnp/4nD7\n k36x0MVGmZxb+lpb8G+U9Dc+BLY7+pu0CPmu0VPhfAvRYAnCLEVRwg3rZzEmzR5zYy9qDC24kTg\n 60/l6sLukK1avgo7FgOctudaZNSOxKTmdvogirw5ugXiDKLE2bJhZJwLb0wZvg+Wc6xzNXP7BHe\n J+gL+8WOIlOybsBD8y4WtlaeohKhUNKrP6y1zte3/vzdNeBIrJ6eF3CC+UJ/z6VfP32AQKUaw6G\n 5JR7Br81FfSu7E8q+QZYVVI362c19+Qd+Qxvk3Xgb4CKMKsHtbVmFaUIbFsAxztpbjUb2bpZuJ1\n Wj4+Y","X-Received":"by 2002:a17:907:1c16:b0:b93:51df:dd23 with SMTP id\n a640c23a62f3a-b9c67650fabmr335573166b.16.1775322144724;\n Sat, 04 Apr 2026 10:02:24 -0700 (PDT)","From":"Ivan Lazaric <ivan.lazaric1@gmail.com>","To":"libstdc++@gcc.gnu.org,\n\tgcc-patches@gcc.gnu.org","Cc":"Ivan Lazaric <ivan.lazaric1@gmail.com>","Subject":"[PATCH] libstdc++: Implement P1789R3: structured bindings for\n std::integer_sequence","Date":"Sat,  4 Apr 2026 19:01:23 +0200","Message-ID":"<20260404170122.2928689-2-ivan.lazaric1@gmail.com>","X-Mailer":"git-send-email 2.43.0","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"},"content":"P1789 enables accessing the sequence values through structured bindings.\n```\nauto [...values] = std::make_index_sequence<10>{};\n// values is a pack of size 10, and elements 0, 1, 2, ..., 9\n```\n\nCorresponding C++ draft commit: 3d71a838ed2a1689dd329f964ec4d58152487151\nFeature-test macro integer_sequence has been bumped to 202511L.\n\nlibstdc++-v3/ChangeLog:\n\n\t* include/bits/utility.h:\n        Implement structured bindings protocol for std::integer_sequence.\n\t* include/bits/version.def: Bump integer_sequence feature-test macro.\n\t* include/bits/version.h: Regenerate.\n\t* testsuite/20_util/integer_sequence/structured_binding.cc: New test.\n\nSigned-off-by: Ivan Lazaric <ivan.lazaric1@gmail.com>\n---\nTested everything under 20_util, including the new test.\n\n libstdc++-v3/include/bits/utility.h           | 28 ++++++++++++++++++\n libstdc++-v3/include/bits/version.def         |  5 ++++\n libstdc++-v3/include/bits/version.h           |  7 ++++-\n .../integer_sequence/structured_binding.cc    | 29 +++++++++++++++++++\n 4 files changed, 68 insertions(+), 1 deletion(-)\n create mode 100644 libstdc++-v3/testsuite/20_util/integer_sequence/structured_binding.cc","diff":"diff --git a/libstdc++-v3/include/bits/utility.h b/libstdc++-v3/include/bits/utility.h\nindex bd6b18d54dd..159884dd814 100644\n--- a/libstdc++-v3/include/bits/utility.h\n+++ b/libstdc++-v3/include/bits/utility.h\n@@ -150,6 +150,34 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n       static constexpr size_t size() noexcept { return sizeof...(_Idx); }\n     };\n \n+#if __glibcxx_integer_sequence >= 202511L // C++ >= 26\n+    template<typename _Tp, _Tp... _Idx>\n+      struct tuple_size<integer_sequence<_Tp, _Idx...>>\n+      : integral_constant<size_t, sizeof...(_Idx)> { };\n+\n+    template<size_t __i, class _Tp, _Tp... _Idx>\n+      struct tuple_element<__i, integer_sequence<_Tp, _Idx...>>\n+      {\n+\tstatic_assert(__i < sizeof...(_Idx));\n+\tusing type = _Tp;\n+      };\n+\n+    template<size_t __i, class _Tp, _Tp... _Idx>\n+      struct tuple_element<__i, const integer_sequence<_Tp, _Idx...>>\n+      {\n+\tstatic_assert(__i < sizeof...(_Idx));\n+\tusing type = _Tp;\n+      };\n+\n+    template<size_t __i, class _Tp, _Tp... _Idx>\n+      constexpr _Tp\n+      get (integer_sequence<_Tp, _Idx...>) noexcept\n+      {\n+\tstatic_assert(__i < sizeof...(_Idx));\n+\treturn _Idx...[__i];\n+      }\n+#endif // __glibcxx_integer_sequence >= 202511L\n+\n   /// Alias template make_integer_sequence\n   template<typename _Tp, _Tp _Num>\n     using make_integer_sequence\ndiff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def\nindex b89e60d156d..6103f6a41d1 100644\n--- a/libstdc++-v3/include/bits/version.def\n+++ b/libstdc++-v3/include/bits/version.def\n@@ -184,6 +184,11 @@ ftms = {\n \n ftms = {\n   name = integer_sequence;\n+  values = {\n+    v = 202511;\n+    cxxmin = 26;\n+    extra_cond = \"__cpp_pack_indexing\";\n+  };\n   values = {\n     v = 201304;\n     cxxmin = 14;\ndiff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h\nindex d73b547e1b0..0de2ad9e5f3 100644\n--- a/libstdc++-v3/include/bits/version.h\n+++ b/libstdc++-v3/include/bits/version.h\n@@ -186,7 +186,12 @@\n #undef __glibcxx_want_exchange_function\n \n #if !defined(__cpp_lib_integer_sequence)\n-# if (__cplusplus >= 201402L)\n+# if (__cplusplus >  202302L) && (__cpp_pack_indexing)\n+#  define __glibcxx_integer_sequence 202511L\n+#  if defined(__glibcxx_want_all) || defined(__glibcxx_want_integer_sequence)\n+#   define __cpp_lib_integer_sequence 202511L\n+#  endif\n+# elif (__cplusplus >= 201402L)\n #  define __glibcxx_integer_sequence 201304L\n #  if defined(__glibcxx_want_all) || defined(__glibcxx_want_integer_sequence)\n #   define __cpp_lib_integer_sequence 201304L\ndiff --git a/libstdc++-v3/testsuite/20_util/integer_sequence/structured_binding.cc b/libstdc++-v3/testsuite/20_util/integer_sequence/structured_binding.cc\nnew file mode 100644\nindex 00000000000..b8e9fa1caa1\n--- /dev/null\n+++ b/libstdc++-v3/testsuite/20_util/integer_sequence/structured_binding.cc\n@@ -0,0 +1,29 @@\n+// { dg-do compile { target c++26 } }\n+\n+#include <utility>\n+\n+#if __cpp_lib_integer_sequence < 202511L\n+# error \"Feature-test macro __cpp_lib_integer_sequence is incorrect\"\n+#endif\n+\n+constexpr auto\n+destructure_sum(auto seq)\n+{\n+  auto [...elems] = seq;\n+  return (0 + ... + elems);\n+}\n+\n+using IS1 = std::make_index_sequence<10>;\n+static_assert(std::tuple_size_v<IS1> == 10);\n+static_assert(std::is_same_v<std::tuple_element_t<3, IS1>, size_t>);\n+static_assert(std::get<7>(IS1{}) == 7);\n+static_assert(destructure_sum(IS1{}) == 45);\n+\n+using IS2 = std::integer_sequence<int, 42, 101, -13>;\n+static_assert(std::tuple_size_v<IS2> == 3);\n+static_assert(std::is_same_v<std::tuple_element_t<1, IS2>, int>);\n+static_assert(std::get<2>(IS2{}) == -13);\n+static_assert(destructure_sum(IS2{}) == 130);\n+\n+using IS3 = std::integer_sequence<char>;\n+static_assert(std::tuple_size_v<IS3> == 0);\n","prefixes":[]}