diff --git a/libcxx/include/optional b/libcxx/include/optional --- a/libcxx/include/optional +++ b/libcxx/include/optional @@ -675,12 +675,11 @@ } }; template - using _CheckOptionalArgsCtor = _If< - _IsNotSame<__remove_cvref_t<_Up>, in_place_t>::value && - _IsNotSame<__remove_cvref_t<_Up>, optional>::value, - _CheckOptionalArgsConstructor, - __check_tuple_constructor_fail - >; + using _CheckOptionalArgsCtor = + _If< _IsNotSame<__remove_cvref_t<_Up>, in_place_t>::value && + _IsNotSame<__remove_cvref_t<_Up>, optional>::value && _IsNotSame<__remove_cvref_t<_Up>, void>::value, + _CheckOptionalArgsConstructor, + __check_tuple_constructor_fail >; template struct _CheckOptionalLikeConstructor { 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; +}