[libcxx-commits] [libcxx] [libc++] Guard `optional::iterator` range variables behind experimental (PR #175222)
William Tran-Viet via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jan 9 13:01:17 PST 2026
https://github.com/smallp-o-p updated https://github.com/llvm/llvm-project/pull/175222
>From 316c461d1d3f4a9e9191ea5c383cb8f0909a266e Mon Sep 17 00:00:00 2001
From: William Tran-Viet <wtranviet at proton.me>
Date: Fri, 9 Jan 2026 14:06:18 -0500
Subject: [PATCH 1/2] Guard range variables behind experimental optional
iterator
---
libcxx/include/optional | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/include/optional b/libcxx/include/optional
index cc6a30151c53a..12fbcdfa5c5d6 100644
--- a/libcxx/include/optional
+++ b/libcxx/include/optional
@@ -661,7 +661,7 @@ using __optional_sfinae_assign_base_t _LIBCPP_NODEBUG =
template <class _Tp>
class optional;
-# if _LIBCPP_STD_VER >= 26
+# if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR
template <class _Tp>
constexpr bool ranges::enable_view<optional<_Tp>> = true;
>From 78ddf02d33f11892c44f052b6efb29034c3d5337 Mon Sep 17 00:00:00 2001
From: William Tran-Viet <wtranviet at proton.me>
Date: Fri, 9 Jan 2026 16:01:08 -0500
Subject: [PATCH 2/2] module inc
---
libcxx/modules/std/optional.inc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libcxx/modules/std/optional.inc b/libcxx/modules/std/optional.inc
index 88de0bb4db12b..8196a8dde577c 100644
--- a/libcxx/modules/std/optional.inc
+++ b/libcxx/modules/std/optional.inc
@@ -10,7 +10,7 @@
export namespace std {
// [optional.optional], class template optional
using std::optional;
-#if _LIBCPP_STD_VER >= 26
+#if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR
// [optional.iterators], iterator support
namespace ranges {
using std::ranges::enable_borrowed_range;
@@ -24,7 +24,7 @@ export namespace std {
// [optional.bad.access], class bad_optional_access
using std::bad_optional_access;
-#if _LIBCPP_STD_VER >= 26
+#if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR
using std::format_kind;
#endif
More information about the libcxx-commits
mailing list