[libcxx-commits] [libcxx] [libc++] Collapse `optional<T&>` inheritance hierarchy (PR #215286)
William Tran-Viet via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Aug 10 18:51:24 PDT 2026
================
@@ -54,40 +54,47 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
-struct __optional_ref_base {
- using value_type = _Tp;
- using __raw_type _LIBCPP_NODEBUG = remove_reference_t<_Tp>;
- __raw_type* __value_;
+struct __optional_ref_iterator_base {};
- _LIBCPP_HIDE_FROM_ABI constexpr __optional_ref_base() noexcept : __value_(nullptr) {}
+# if _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR
+
+template <class _Tp>
+ requires(is_object_v<_Tp> && !__is_unbounded_array_v<_Tp>)
+struct __optional_ref_iterator_base<_Tp&> {
+# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_OPTIONAL
+ using iterator = __bounded_iter<_Tp*>;
+# else
+ using iterator = __capacity_aware_iterator<_Tp*, optional<_Tp&>, 1>;
+# endif
+};
+
+# endif
+
+template <class _Tp>
+class _LIBCPP_DECLSPEC_EMPTY_BASES optional<_Tp&> : public __optional_ref_iterator_base<_Tp&> {
----------------
smallp-o-p wrote:
I do not think we test for it.
https://github.com/llvm/llvm-project/pull/215286
More information about the libcxx-commits
mailing list