[libcxx-commits] [libcxx] [libc++][NFC] Simplify `optional<T>` and `optional<T&>` a bit (PR #203665)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jun 13 23:05:37 PDT 2026


================
@@ -792,49 +769,56 @@ template <class _Tp>
 inline constexpr bool __is_valid_optional_contained_type = is_object_v<_Tp> || is_lvalue_reference_v<_Tp>;
 #    endif
 
-template <class _Tp, class = void>
+template <class _Tp>
 struct __optional_iterator_base : __optional_move_assign_base<_Tp> {
   using __optional_move_assign_base<_Tp>::__optional_move_assign_base;
 };
 
-#    if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR
+#    if _LIBCPP_STD_VER >= 26
+template <class _Tp>
+struct __optional_iterator_base<_Tp&> : __optional_storage_base<_Tp&> {
----------------
frederick-vs-ja wrote:

Thanks!

IMO, in the future, we may consider turning `__optional_iterator_base<_Tp&>` and `__optional_storage_base<_Tp&>` into separated class templates.

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


More information about the libcxx-commits mailing list