get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2226689/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2226689,
    "url": "http://patchwork.ozlabs.org/api/patches/2226689/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/bmm.hhuogh01ko.gcc.gcc-TEST.peppe.54.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.hhuogh01ko.gcc.gcc-TEST.peppe.54.1.1@forge-stage.sourceware.org>",
    "list_archive_url": null,
    "date": "2026-04-22T18:24:54",
    "name": "[v1,1/1] libstdc++: add range support to std::optional (P3168)",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "7f43c6851db80fbcfe9ee65bbb96b91aa59eaec8",
    "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.hhuogh01ko.gcc.gcc-TEST.peppe.54.1.1@forge-stage.sourceware.org/mbox/",
    "series": [
        {
            "id": 501073,
            "url": "http://patchwork.ozlabs.org/api/series/501073/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=501073",
            "date": "2026-04-22T18:24:53",
            "name": "WIP: libstdc++: add range support to std::optional (P3168)",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/501073/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2226689/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2226689/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=38.145.34.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 [38.145.34.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 4g17840rsBz1yD5\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 23 Apr 2026 04:30:44 +1000 (AEST)",
            "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 162724314EB4\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 18:30:42 +0000 (GMT)",
            "from forge-stage.sourceware.org (vm08.sourceware.org [38.145.34.39])\n by sourceware.org (Postfix) with ESMTPS id 1D3C843B8AAF\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 18:25:46 +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 EAC7343469\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 18:25:45 +0000 (UTC)"
        ],
        "DKIM-Filter": [
            "OpenDKIM Filter v2.11.0 sourceware.org 162724314EB4",
            "OpenDKIM Filter v2.11.0 sourceware.org 1D3C843B8AAF"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 1D3C843B8AAF",
        "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 1D3C843B8AAF",
        "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776882346; cv=none;\n b=AHeLLn60uhU/lyKObSpCkDj+jQRtdfh6vywGzbMLxo1lDvtRBRfq67lnyXCjBG1K6brTiHL8rRdSgJZvvPpfRjT2tCRakCPHeffPv9DhUodV3QvtZkaVKecqCqbd2HWDy90bMmRivTicV5ke9KisbA4D8Bdq/wTN1KOcVbMu5rI=",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776882346; c=relaxed/simple;\n bh=As+t3I+2sX5yEnFRxVytOBf02gZQclpl7sj9It6kUAU=;\n h=From:Date:Subject:To:Message-ID;\n b=KTEq3JTDXR3d/bB2Gjz1Nzi6XNASC0MMGTbfC9/uTQXkU70ZMdtNuzLqr6eKVFNpmf6wi+qnYjOv02g/w4MJmmvzN0vR/TVpgStL+FD8RF9M17V51kzbIvOdb2K81aOEUez14D+H0Pkc+MpxUi5Kjj8qQN5tGg6hfM2wFijViOc=",
        "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:24:54 +0000",
        "Subject": "[PATCH v1 1/1] libstdc++: add range support to std::optional (P3168)",
        "To": "gcc-patches mailing list <gcc-patches@gcc.gnu.org>",
        "Message-ID": "\n <bmm.hhuogh01ko.gcc.gcc-TEST.peppe.54.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/54",
        "References": "\n <bmm.hhuogh01ko.gcc.gcc-TEST.peppe.54.1.0@forge-stage.sourceware.org>",
        "In-Reply-To": "\n <bmm.hhuogh01ko.gcc.gcc-TEST.peppe.54.1.0@forge-stage.sourceware.org>",
        "X-Patch-URL": "\n https://forge.sourceware.org/peppe/gcc-TEST/commit/2df2898b525ff502924e33df4d0ad94b0c11ddfe",
        "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 implements P3168 (\"Give std::optional Range Support\"), added\nfor C++26. Both begin() and end() are straightforward, implemented using\nnormal_iterator over a raw pointer.\n\nstd::optional is also a view, so specialize enable_view for it.\n\nWe also need to disable automatic formatting a std::optional as a range\nby specializing format_kind. In order to avoid dragging <format> when\nincluding <optional>, I've isolated format_kind and some supporting code\ninto <bits/formatfwd.h> so that I can use that (comparatively) lighter\nheader.\n\nlibstdc++-v3/ChangeLog:\n\n\t* include/bits/formatfwd.h (format_kind): Move the definition\n\t(and some supporting code) from <format>; adjust inclusions.\n\t* include/std/format (format_kind): Likewise.\n\t* include/bits/version.def (optional_range_support): Add\n\tthe feature-testing macro.\n\t* include/bits/version.h: Regenerate.\n\t* include/std/optional (iterator, const_iterator, begin, end):\n\tAdd range support.\n\t(enable_view): Specialize for std::optional.\n\t(format_kind): Specialize for std::optional.\n\t* testsuite/20_util/optional/range.cc: New test.\n\t* testsuite/20_util/optional/version.cc: Test the new\n\tfeature-testing macro.\n---\n libstdc++-v3/include/bits/formatfwd.h         |  26 +++\n libstdc++-v3/include/bits/version.def         |   8 +\n libstdc++-v3/include/bits/version.h           |  10 ++\n libstdc++-v3/include/std/format               |  26 ---\n libstdc++-v3/include/std/optional             |  47 +++++\n .../testsuite/20_util/optional/range.cc       | 163 ++++++++++++++++++\n .../testsuite/20_util/optional/version.cc     |  18 ++\n 7 files changed, 272 insertions(+), 26 deletions(-)\n create mode 100644 libstdc++-v3/testsuite/20_util/optional/range.cc",
    "diff": "diff --git a/libstdc++-v3/include/bits/formatfwd.h b/libstdc++-v3/include/bits/formatfwd.h\nindex 777e6290f744..314b55d50bcd 100644\n--- a/libstdc++-v3/include/bits/formatfwd.h\n+++ b/libstdc++-v3/include/bits/formatfwd.h\n@@ -162,6 +162,32 @@ namespace __format\n     using __maybe_const\n       = __conditional_t<formattable<const _Tp, _CharT>, const _Tp, _Tp>;\n }\n+\n+  // [format.range], formatting of ranges\n+  // [format.range.fmtkind], variable template format_kind\n+  enum class range_format {\n+    disabled,\n+    map,\n+    set,\n+    sequence,\n+    string,\n+    debug_string\n+  };\n+\n+  /** @brief A constant determining how a range should be formatted.\n+   *\n+   * The primary template of `std::format_kind` cannot be instantiated.\n+   * There is a partial specialization for input ranges and you can\n+   * specialize the variable template for your own cv-unqualified types\n+   * that satisfy the `ranges::input_range` concept.\n+   *\n+   * @since C++23\n+   */\n+  template<typename _Rg>\n+    constexpr auto format_kind = []{\n+      static_assert(false, \"cannot use primary template of 'std::format_kind'\");\n+      return type_identity<_Rg>{};\n+    }();\n #endif // format_ranges\n \n _GLIBCXX_END_NAMESPACE_VERSION\ndiff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def\nindex 9ab22cc519f9..f864ea11baea 100644\n--- a/libstdc++-v3/include/bits/version.def\n+++ b/libstdc++-v3/include/bits/version.def\n@@ -851,6 +851,14 @@ ftms = {\n   };\n };\n \n+ftms = {\n+  name = optional_range_support;\n+  values = {\n+    v = 202406;\n+    cxxmin = 26;\n+  };\n+};\n+\n ftms = {\n   name = destroying_delete;\n   values = {\ndiff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h\nindex 371a7ba3b1a0..1611132cf21b 100644\n--- a/libstdc++-v3/include/bits/version.h\n+++ b/libstdc++-v3/include/bits/version.h\n@@ -955,6 +955,16 @@\n #endif /* !defined(__cpp_lib_optional) && defined(__glibcxx_want_optional) */\n #undef __glibcxx_want_optional\n \n+#if !defined(__cpp_lib_optional_range_support)\n+# if (__cplusplus >  202302L)\n+#  define __glibcxx_optional_range_support 202406L\n+#  if defined(__glibcxx_want_all) || defined(__glibcxx_want_optional_range_support)\n+#   define __cpp_lib_optional_range_support 202406L\n+#  endif\n+# endif\n+#endif /* !defined(__cpp_lib_optional_range_support) && defined(__glibcxx_want_optional_range_support) */\n+#undef __glibcxx_want_optional_range_support\n+\n #if !defined(__cpp_lib_destroying_delete)\n # if (__cplusplus >= 202002L) && (__cpp_impl_destroying_delete)\n #  define __glibcxx_destroying_delete 201806L\ndiff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format\nindex b4929d5ae59f..a29aafd9ac10 100644\n--- a/libstdc++-v3/include/std/format\n+++ b/libstdc++-v3/include/std/format\n@@ -5472,32 +5472,6 @@ namespace __format\n #endif\n \n #if __glibcxx_format_ranges // C++ >= 23 && HOSTED\n-  // [format.range], formatting of ranges\n-  // [format.range.fmtkind], variable template format_kind\n-  enum class range_format {\n-    disabled,\n-    map,\n-    set,\n-    sequence,\n-    string,\n-    debug_string\n-  };\n-\n-  /** @brief A constant determining how a range should be formatted.\n-   *\n-   * The primary template of `std::format_kind` cannot be instantiated.\n-   * There is a partial specialization for input ranges and you can\n-   * specialize the variable template for your own cv-unqualified types\n-   * that satisfy the `ranges::input_range` concept.\n-   *\n-   * @since C++23\n-   */\n-  template<typename _Rg>\n-    constexpr auto format_kind = []{\n-      static_assert(false, \"cannot use primary template of 'std::format_kind'\");\n-      return type_identity<_Rg>{};\n-    }();\n-\n   /// @cond undocumented\n   template<typename _Tp>\n     consteval range_format\ndiff --git a/libstdc++-v3/include/std/optional b/libstdc++-v3/include/std/optional\nindex a616dc07b107..2ae71f11e213 100644\n--- a/libstdc++-v3/include/std/optional\n+++ b/libstdc++-v3/include/std/optional\n@@ -36,6 +36,7 @@\n \n #define __glibcxx_want_freestanding_optional\n #define __glibcxx_want_optional\n+#define __glibcxx_want_optional_range_support\n #define __glibcxx_want_constrained_equality\n #include <bits/version.h>\n \n@@ -57,6 +58,11 @@\n #if __cplusplus > 202002L\n # include <concepts>\n #endif\n+#ifdef __cpp_lib_optional_range_support // C++ >= 26\n+# include <bits/formatfwd.h>\n+# include <bits/ranges_base.h>\n+# include <bits/stl_iterator.h>\n+#endif\n \n namespace std _GLIBCXX_VISIBILITY(default)\n {\n@@ -858,6 +864,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n \n     public:\n       using value_type = _Tp;\n+#ifdef __cpp_lib_optional_range_support // >= C++26\n+      using iterator = __gnu_cxx::__normal_iterator<_Tp*, optional>;\n+      using const_iterator = __gnu_cxx::__normal_iterator<const _Tp*, optional>;\n+#endif\n \n       constexpr optional() noexcept { }\n \n@@ -1158,6 +1168,33 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n \t  }\n       }\n \n+#ifdef __cpp_lib_optional_range_support // >= C++26\n+      // Iterator support.\n+      constexpr iterator begin() noexcept\n+      {\n+\treturn iterator(\n+\t  this->_M_is_engaged() ? std::addressof(this->_M_get()) : nullptr\n+\t);\n+      }\n+\n+      constexpr const_iterator begin() const noexcept\n+      {\n+\treturn const_iterator(\n+\t  this->_M_is_engaged() ? std::addressof(this->_M_get()) : nullptr\n+\t);\n+      }\n+\n+      constexpr iterator end() noexcept\n+      {\n+\treturn begin() + has_value();\n+      }\n+\n+      constexpr const_iterator end() const noexcept\n+      {\n+\treturn begin() + has_value();\n+      }\n+#endif // __cpp_lib_optional_range_support\n+\n       // Observers.\n       constexpr const _Tp*\n       operator->() const noexcept\n@@ -1772,6 +1809,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n   template <typename _Tp> optional(_Tp) -> optional<_Tp>;\n #endif\n \n+#ifdef __cpp_lib_optional_range_support // >= C++26\n+  template<typename _Tp>\n+    inline constexpr bool\n+      ranges::enable_view<optional<_Tp>> = true;\n+\n+  template<typename _Tp>\n+    inline constexpr auto\n+      format_kind<optional<_Tp>> = range_format::disabled;\n+#endif // __cpp_lib_optional_range_support\n+\n #undef _GLIBCXX_USE_CONSTRAINTS_FOR_OPTIONAL\n \n _GLIBCXX_END_NAMESPACE_VERSION\ndiff --git a/libstdc++-v3/testsuite/20_util/optional/range.cc b/libstdc++-v3/testsuite/20_util/optional/range.cc\nnew file mode 100644\nindex 000000000000..e77dc21e22b3\n--- /dev/null\n+++ b/libstdc++-v3/testsuite/20_util/optional/range.cc\n@@ -0,0 +1,163 @@\n+// { dg-do compile { target c++26 } }\n+\n+#include <concepts>\n+#include <format>\n+#include <iterator>\n+#include <optional>\n+#include <ranges>\n+#include <string_view>\n+#include <vector>\n+\n+#include <testsuite_hooks.h>\n+\n+template<typename O>\n+constexpr\n+void\n+test_range_concepts()\n+{\n+  static_assert(std::ranges::contiguous_range<O>);\n+  static_assert(std::ranges::sized_range<O>);\n+  static_assert(std::ranges::common_range<O>);\n+  static_assert(!std::ranges::borrowed_range<O>);\n+\n+  // an optional<const T> is not assignable, and therefore does not satisfy ranges::view\n+  using T = typename O::value_type;\n+  constexpr bool is_const_opt = std::is_const_v<T>;\n+  static_assert(std::ranges::view<O> == !is_const_opt);\n+  static_assert(std::ranges::viewable_range<O> == !is_const_opt);\n+}\n+\n+template<typename O>\n+constexpr\n+void\n+test_iterator_concepts()\n+{\n+  using T = typename O::value_type;\n+  using iterator = typename O::iterator;\n+  static_assert(std::contiguous_iterator<iterator>);\n+  static_assert(std::is_same_v<typename std::iterator_traits<iterator>::value_type, std::remove_cv_t<T>>);\n+  static_assert(std::is_same_v<std::iter_value_t<iterator>, std::remove_cv_t<T>>);\n+  static_assert(std::is_same_v<typename std::iterator_traits<iterator>::reference, T&>);\n+  static_assert(std::is_same_v<std::iter_reference_t<iterator>, T&>);\n+\n+  using const_iterator = typename O::const_iterator;\n+  static_assert(std::contiguous_iterator<const_iterator>);\n+  static_assert(std::is_same_v<typename std::iterator_traits<const_iterator>::value_type, std::remove_cv_t<T>>);\n+  static_assert(std::is_same_v<std::iter_value_t<const_iterator>, std::remove_cv_t<T>>);\n+  static_assert(std::is_same_v<typename std::iterator_traits<const_iterator>::reference, const T&>);\n+  static_assert(std::is_same_v<std::iter_reference_t<const_iterator>, const T&>);\n+}\n+\n+template<typename O>\n+constexpr\n+void\n+test_empty()\n+{\n+  O empty;\n+  VERIFY(!empty);\n+  VERIFY(empty.begin() == empty.end());\n+  VERIFY(std::as_const(empty).begin() == std::as_const(empty).end());\n+  VERIFY(std::ranges::empty(empty));\n+  VERIFY(std::ranges::empty(std::as_const(empty)));\n+  VERIFY(std::ranges::empty(empty | std::views::as_const));\n+  VERIFY(std::ranges::size(empty) == 0);\n+  VERIFY(std::ranges::size(std::as_const(empty)) == 0);\n+\n+  size_t count = 0;\n+  for (const auto& x : empty)\n+    ++count;\n+  VERIFY(count == 0);\n+}\n+\n+template<typename O, typename T>\n+constexpr\n+void\n+test_non_empty(const T& value)\n+{\n+  O non_empty = std::make_optional(value);\n+  VERIFY(non_empty);\n+  VERIFY(*non_empty == value);\n+  VERIFY(non_empty.begin() != non_empty.end());\n+  VERIFY(non_empty.begin() < non_empty.end());\n+  VERIFY(std::as_const(non_empty).begin() != std::as_const(non_empty).end());\n+  VERIFY(std::as_const(non_empty).begin() < std::as_const(non_empty).end());\n+  VERIFY(!std::ranges::empty(non_empty));\n+  VERIFY(!std::ranges::empty(std::as_const(non_empty)));\n+  VERIFY(!std::ranges::empty(non_empty | std::views::as_const));\n+  VERIFY(std::ranges::size(non_empty) == 1);\n+  VERIFY(std::ranges::size(std::as_const(non_empty)) == 1);\n+\n+  size_t count = 0;\n+  for (const auto& x : non_empty)\n+    ++count;\n+  VERIFY(count == 1);\n+\n+  if constexpr (!std::is_const_v<typename O::value_type>) {\n+    for (auto& x : non_empty)\n+      x = T{};\n+    VERIFY(non_empty);\n+    VERIFY(*non_empty == T{});\n+  }\n+}\n+\n+template<typename T>\n+constexpr\n+void\n+test(const T& value)\n+{\n+  using O = std::optional<T>;\n+  test_range_concepts<O>();\n+  test_iterator_concepts<O>();\n+  test_empty<O>();\n+  test_non_empty<O>(value);\n+  static_assert(!std::formattable<O, char>);\n+  static_assert(!std::formattable<O, wchar_t>);\n+  static_assert(std::format_kind<O> == std::range_format::disabled);\n+}\n+\n+constexpr\n+void\n+range_chain_example() // from P3168\n+{\n+  std::vector<int> v{2, 3, 4, 5, 6, 7, 8, 9, 1};\n+  auto test = [](int i) -> std::optional<int> {\n+    switch(i) {\n+    case 1:\n+    case 3:\n+    case 7:\n+    case 9:\n+      return i * 2;\n+    default:\n+      return {};\n+    }\n+  };\n+\n+  auto result = v\n+    | std::views::transform(test)\n+    | std::views::filter([](auto x) { return bool(x); })\n+    | std::views::transform([](auto x){ return *x; })\n+    | std::ranges::to<std::vector>();\n+\n+  bool ok = result == std::vector<int>{6, 14, 18, 2};\n+  VERIFY(ok);\n+}\n+\n+constexpr\n+bool\n+all_tests()\n+{\n+  test(42);\n+  int i = 42;\n+  test(&i);\n+  test(std::string_view(\"test\"));\n+  test(std::vector<int>{1, 2, 3, 4});\n+  test(std::optional<int>(42));\n+  test<const int>(42);\n+\n+  range_chain_example();\n+\n+  return true;\n+}\n+\n+static_assert(all_tests());\n+\ndiff --git a/libstdc++-v3/testsuite/20_util/optional/version.cc b/libstdc++-v3/testsuite/20_util/optional/version.cc\nindex 657a3992422a..ba44aa525356 100644\n--- a/libstdc++-v3/testsuite/20_util/optional/version.cc\n+++ b/libstdc++-v3/testsuite/20_util/optional/version.cc\n@@ -21,8 +21,17 @@\n #endif\n #endif\n \n+#if __cplusplus > 202302L\n+# ifndef __cpp_lib_optional_range_support\n+#  error \"Feature test macro for optional range support is missing in <version>\"\n+# elif __cpp_lib_optional_range_support != 202406L\n+#  error \"Feature test macro for optional range support has wrong value for C++26 in <version>\"\n+# endif\n+#endif\n+\n #undef __cpp_lib_optional\n #undef __cpp_lib_freestanding_optional\n+#undef __cpp_lib_optional_range_support\n #include <optional>\n \n #if __cplusplus >= 202302L\n@@ -32,3 +41,12 @@\n # error \"Feature test macro for freestanding std::optional has wrong value in <optional>\"\n #endif\n #endif\n+\n+#if __cplusplus > 202302L\n+# ifndef __cpp_lib_optional_range_support\n+#  error \"Feature test macro for optional range support is missing in <optional>\"\n+# endif\n+# if __cpp_lib_optional_range_support != 202406L\n+#  error \"Feature test macro for optional range support has wrong value for C++26 in <optional>\"\n+# endif\n+#endif\n",
    "prefixes": [
        "v1",
        "1/1"
    ]
}