[libcxx-commits] [libcxx] [libc++] Reimplement `optional<T&>` as a partial specialization (PR #201983)
William Tran-Viet via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jun 9 12:53:13 PDT 2026
================
@@ -1343,24 +1220,137 @@ public:
# endif // _LIBCPP_STD_VER >= 23
using __base::reset;
+};
-// optional<T&> overloads
# if _LIBCPP_STD_VER >= 26
+template <class _Tp>
+class optional<_Tp&> : public __optional_iterator_base<_Tp&> {
----------------
smallp-o-p wrote:
For `__optional_iterator_base`, we need `optional::iterator`, which inherits in that long chain of empty bases all the way to `__optional_storage_base`. There is a lot of room for simplification there by making `__optional_iterator_base` inherit directly from the storage base, but I think that should go in a different patch to not bloat this one.
https://github.com/llvm/llvm-project/pull/201983
More information about the libcxx-commits
mailing list