diff --git a/libcxx/include/optional b/libcxx/include/optional --- a/libcxx/include/optional +++ b/libcxx/include/optional @@ -662,16 +662,16 @@ // LWG2756: conditionally explicit conversion from _Up struct _CheckOptionalArgsConstructor { - template + template > static constexpr bool __enable_implicit() { - return is_constructible_v<_Tp, _Up&&> && - is_convertible_v<_Up&&, _Tp>; + return is_constructible_v<_Tp, _UpRR> && + is_convertible_v<_UpRR, _Tp>; } - template + template > static constexpr bool __enable_explicit() { - return is_constructible_v<_Tp, _Up&&> && - !is_convertible_v<_Up&&, _Tp>; + return is_constructible_v<_Tp, _UpRR> && + !is_convertible_v<_UpRR, _Tp>; } }; template diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/ambigous_constructor.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/ambigous_constructor.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/ambigous_constructor.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14 +// + +#include + +#include "test_macros.h" + +struct Bar { + int s; +}; + +struct Foo { + Foo(Bar) {} + Foo(std::optional) {} +}; + +int main(int, char**) { + Foo foo{{.s = 42}}; + + return 0; +}