[libcxx-commits] [libcxx] [libc++] Implement P3168R2: Give optional range support (PR #149441)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Mon Aug 11 06:40:31 PDT 2025


================
@@ -579,16 +607,49 @@ struct __is_std_optional : false_type {};
 template <class _Tp>
 struct __is_std_optional<optional<_Tp>> : true_type {};
 
+template <class _Tp, class = void>
+struct __optional_iterator_aliases {};
+
+#    if _LIBCPP_STD_VER >= 26
+// disallow T (&)() and T (&)[]
+template <class _Tp>
+struct __optional_iterator_aliases<
+    _Tp,
+    __enable_if_t<!(is_reference<_Tp>::value && (is_function<__libcpp_remove_reference_t<_Tp>>::value ||
+                                                 is_unbounded_array<__libcpp_remove_reference_t<_Tp>>::value))> > {
----------------
philnik777 wrote:

IMO we should tackle it then. It's not clear to me that we even want to allow these kinds of instantiations, and I'm very much not a fan of working around problems that don't even exist yet.

https://github.com/llvm/llvm-project/pull/149441


More information about the libcxx-commits mailing list