From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 29B243858CD1; Fri, 23 Jun 2023 12:56:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 29B243858CD1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687525011; bh=yBFyxXcrc1TKx+O0hyPJchgVgxnGCLjKRxgdtrfr/Ho=; h=From:To:Subject:Date:From; b=FrO58K9AQ4u1jMRaTCUbd8htT38yuf3Jluy08cIjIn9N50R6otWd6Iln+vcSXWPsy fymydpQcYbCdUdFYGzLyA+rGmdKeKlM6i418bUjV7vh86JSY1Cl3ton2rcKQAlGfvH amY6iUH5luxJwg9l0Geu940WqyWFwzQISupvJhk4= 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 r11-10870] libstdc++: Simplify constraints for std::any construction [PR104242] X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: 8c150c7618cc76baf0c8bb278f541b327039b160 X-Git-Newrev: 5fc6b3a03355e1f77a7c38c0fa7afb0822ad954f Message-Id: <20230623125651.29B243858CD1@sourceware.org> Date: Fri, 23 Jun 2023 12:56:51 +0000 (GMT) List-Id: https://gcc.gnu.org/g:5fc6b3a03355e1f77a7c38c0fa7afb0822ad954f commit r11-10870-g5fc6b3a03355e1f77a7c38c0fa7afb0822ad954f Author: Jonathan Wakely Date: Fri Mar 18 13:10:01 2022 +0000 libstdc++: Simplify constraints for std::any construction [PR104242] Partially revert r12-4190-g6da36b7d0e43b6f9281c65c19a025d4888a25b2d because using __and_<..., is_copy_constructible> when T is incomplete results in an error about deriving from is_copy_constructible when that is incomplete. I don't know how to fix that, so this simply restores the previous constraint which worked in this case (even though I think it's technically undefined to use is_copy_constructible with incomplete T). This doesn't restore exactly what we had before, but uses the is_copy_constructible_v and __is_in_place_type_v variable templates instead of the ::value member. libstdc++-v3/ChangeLog: PR libstdc++/104242 * include/std/any (any(T&&)): Revert change to constraints. * testsuite/20_util/any/cons/104242.cc: New test. (cherry picked from commit 7a42b1fa1a090ead96cc0f94a8060a9650c810d5) Diff: --- libstdc++-v3/include/std/any | 4 ++-- libstdc++-v3/testsuite/20_util/any/cons/104242.cc | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any index d96ea06c1ae..5aec4040064 100644 --- a/libstdc++-v3/include/std/any +++ b/libstdc++-v3/include/std/any @@ -184,8 +184,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Construct with a copy of @p __value as the contained object. template , typename _Mgr = _Manager<_VTp>, - typename = _Require<__not_<__is_in_place_type<_VTp>>, - is_copy_constructible<_VTp>>> + enable_if_t + && !__is_in_place_type_v<_VTp>, bool> = true> any(_Tp&& __value) : _M_manager(&_Mgr::_S_manage) { diff --git a/libstdc++-v3/testsuite/20_util/any/cons/104242.cc b/libstdc++-v3/testsuite/20_util/any/cons/104242.cc new file mode 100644 index 00000000000..8d5868b7ff9 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/any/cons/104242.cc @@ -0,0 +1,12 @@ +// { dg-do compile { target c++17 } } + +// PR libstdc++/104242 - Class with constructor from std::any is not copyable + +#include +#include + +struct A { + A(const A&) = default; + explicit A(std::any value); +}; +static_assert(std::is_copy_constructible_v);