[libcxx-commits] [libcxx] [libc++] Fix bug where optional<T&> couldn't be constructed from a monadic operation (PR #203462)

William Tran-Viet via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jun 11 23:46:10 PDT 2026


================
@@ -571,6 +571,14 @@ struct __optional_storage_base<_Tp, true> {
     __convert_init_ref_val(std::forward<_UArg>(__uarg));
   }
 
+#    if _LIBCPP_STD_VER >= 23
+  template <class _Fp, class... _Args>
+  constexpr __optional_storage_base(__optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args) {
+    _Tp& __r = std::invoke(std::forward<_Fp>(__f), std::forward<_Args>(__args)...);
----------------
smallp-o-p wrote:

Gah, that slipped my mind for some reason. Fixed to use `convert-ref-init-val`.

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


More information about the libcxx-commits mailing list