From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 7A432384841B; Mon, 14 Jun 2021 14:11:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7A432384841B MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-1430] libstdc++: Fix std::any constraints [PR101034] X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 046198673c3776e36ebe0542a86291ed7134fc40 X-Git-Newrev: 14f26c75d255ef05b706a12d25b003da8a2f5b45 Message-Id: <20210614141103.7A432384841B@sourceware.org> Date: Mon, 14 Jun 2021 14:11:03 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Jun 2021 14:11:03 -0000 https://gcc.gnu.org/g:14f26c75d255ef05b706a12d25b003da8a2f5b45 commit r12-1430-g14f26c75d255ef05b706a12d25b003da8a2f5b45 Author: Jonathan Wakely Date: Mon Jun 14 14:18:33 2021 +0100 libstdc++: Fix std::any constraints [PR101034] PR libstdc++/101034 libstdc++-v3/ChangeLog: * include/std/any (any(in_place_t, initializer_list, A&&...)) (any::emplace(initializer_list, A&&...)): Fix constraint to use lvalue. * testsuite/20_util/any/cons/101034.cc: New test. Diff: --- libstdc++-v3/include/std/any | 4 ++-- libstdc++-v3/testsuite/20_util/any/cons/101034.cc | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any index 21120a9146f..a6995b79c43 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) @@ -269,7 +269,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);