[libcxx-commits] [libcxx] [libc++] Implement P2988R12: `std::optional<T&>` (PR #155202)

William Tran-Viet via libcxx-commits libcxx-commits at lists.llvm.org
Fri Nov 7 18:06:11 PST 2025


================
@@ -754,6 +823,41 @@ public:
     this->__construct_from(std::move(__v));
   }
 
+  // deleted optional<T&> constructors
+#    if _LIBCPP_STD_VER >= 26
+  template <class _Up,
+            class... _Args,
+            enable_if_t<is_constructible_v<value_type, initializer_list<_Up>&, _Args...>, int> = 0>
+    requires __libcpp_opt_ref_ctor_deleted<_Up>
+  _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args) = delete;
----------------
smallp-o-p wrote:

All `= delete` functions don't have `_LIBCPP_HIDE_FROM_ABI` and these functions shouldn't ever get it's own symbols, so I think it should be fine to remove `_LIBCPP_HIDE_FROM_ABI` from them. 

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


More information about the libcxx-commits mailing list