diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any index 391e43339a0..ccc27c54e28 100644 --- a/libstdc++-v3/include/std/any +++ b/libstdc++-v3/include/std/any @@ -205,7 +205,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// the contained object. template , typename _Mgr = _Manager<_VTp>, - __any_constructible_t<_VTp, initializer_list<_Up>, + __any_constructible_t<_VTp, initializer_list<_Up>&, _Args&&...> = false> explicit any(in_place_type_t<_Tp>, initializer_list<_Up> __il, _Args&&... __args) @@ -271,7 +271,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Emplace with an object created from @p __il and @p __args as /// the contained object. template - __emplace_t, initializer_list<_Up>, _Args&&...> + __emplace_t, initializer_list<_Up>&, _Args&&...> emplace(initializer_list<_Up> __il, _Args&&... __args) { using _VTp = decay_t<_Tp>; diff --git a/libstdc++-v3/testsuite/20_util/any/cons/101034.cc b/libstdc++-v3/testsuite/20_util/any/cons/101034.cc new file mode 100644 index 00000000000..55f550a839e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/any/cons/101034.cc @@ -0,0 +1,11 @@ +// { dg-do compile { target c++17 } } +// PR libstdc++/101034 - wrong constraint in std::any's constructor + +#include + +struct S { + S(std::initializer_list&, int) {} +}; + +std::any a(std::in_place_type, {0}, 0); +S& s = a.emplace({0}, 0);