[libcxx-commits] [libcxx] [libc++] Implement P3168R2: Give optional range support (PR #149441)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Aug 15 22:47:56 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))> > {
----------------
frederick-vs-ja wrote:
See [LWG4304](https://cplusplus.github.io/LWG/issue4304). I think I was just too nervous about `optional<NonReturnable&>`, maybe it's better to delay adding then special handling during implementing `optional<T&>`.
https://github.com/llvm/llvm-project/pull/149441
More information about the libcxx-commits
mailing list