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,36 @@ +//===----------------------------------------------------------------------===// +// +// 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 +#include +#include + +#include "test_macros.h" + +using std::optional; +using std::string; + +struct Outer { + struct Inner { + optional s; + }; + Outer(Inner&& inner) noexcept : inner_(std::move(inner)) {} + explicit Outer(std::optional s) noexcept { inner_.s = s; } + + Inner inner_; +}; + +int main(int, char**) { + Outer __test{{.s = "hello"}}; + + return 0; +} \ No newline at end of file