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

Hristo Hristov via libcxx-commits libcxx-commits at lists.llvm.org
Thu Oct 30 21:25:50 PDT 2025


================
@@ -482,6 +474,16 @@ struct __optional_storage_base<_Tp, true> {
         __construct(std::forward<_That>(__opt).__get());
     }
   }
+
+  template <class _Up>
+  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __assign_from_val(_Up&& __val) {
+    __value_ = std::addressof(__val);
+  }
+
+  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __swap(__optional_storage_base& __rhs) {
+    using std::swap;
+    swap(__value_, __rhs.__value_);
----------------
Zingam wrote:

Why not `std::swap`?

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


More information about the libcxx-commits mailing list