diff --git a/stl/inc/optional b/stl/inc/optional index 6ce1bcf4c3..b6d4bcc69f 100644 --- a/stl/inc/optional +++ b/stl/inc/optional @@ -214,6 +214,16 @@ class optional : private _SMF_control<_Optional_construct_base<_Ty>, _Ty> { private: using _Mybase = _SMF_control<_Optional_construct_base<_Ty>, _Ty>; + template + friend class optional; + +#if _HAS_CXX23 + template + constexpr optional(_Construct_from_invoke_result_tag _Tag, _Fn&& _Func, _Ux&& _Arg) + noexcept(noexcept(static_cast<_Ty>(_STD invoke(_STD forward<_Fn>(_Func), _STD forward<_Ux>(_Arg))))) + : _Mybase(_Tag, _STD forward<_Fn>(_Func), _STD forward<_Ux>(_Arg)) {} +#endif // _HAS_CXX23 + public: static_assert(!_Is_any_of_v, nullopt_t, in_place_t>, "T in optional must be a type other than nullopt_t or in_place_t (N4950 [optional.optional.general]/3)."); @@ -273,13 +283,6 @@ public: } } -#if _HAS_CXX23 - template - constexpr optional(_Construct_from_invoke_result_tag _Tag, _Fn&& _Func, _Ux&& _Arg) - noexcept(noexcept(static_cast<_Ty>(_STD invoke(_STD forward<_Fn>(_Func), _STD forward<_Ux>(_Arg))))) - : _Mybase(_Tag, _STD forward<_Fn>(_Func), _STD forward<_Ux>(_Arg)) {} -#endif // _HAS_CXX23 - _CONSTEXPR20 optional& operator=(nullopt_t) noexcept { reset(); return *this; diff --git a/tests/libcxx/expected_results.txt b/tests/libcxx/expected_results.txt index 1303fc8710..a9bab3c4f5 100644 --- a/tests/libcxx/expected_results.txt +++ b/tests/libcxx/expected_results.txt @@ -1225,9 +1225,6 @@ std/numerics/c.math/hermite.pass.cpp FAIL # Not analyzed. Test coverage for LLVM-104496 uses span. std/containers/views/views.span/span.cons/copy.pass.cpp FAIL -# Not analyzed. LLVM-103409 added a test to verify that std::optional's internal constructors aren't visible to users. -std/utilities/optional/optional.object/optional.object.ctor/gh_101960_internal_ctor.compile.pass.cpp FAIL - # *** XFAILS WHICH PASS *** # These tests contain `// XFAIL: msvc` comments, which accurately describe runtime failures for x86 and x64.