From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id D31E83858D3C for ; Fri, 18 Mar 2022 15:43:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D31E83858D3C Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-523-m2_5g0xzM4yM-Iig-ZOhiw-1; Fri, 18 Mar 2022 11:43:05 -0400 X-MC-Unique: m2_5g0xzM4yM-Iig-ZOhiw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B558A805F7C; Fri, 18 Mar 2022 15:43:04 +0000 (UTC) Received: from localhost (unknown [10.33.36.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E728401E74; Fri, 18 Mar 2022 15:43:04 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Simplify constraints for std::any construction [PR104242] Date: Fri, 18 Mar 2022 15:43:03 +0000 Message-Id: <20220318154303.532138-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, URI_HEX autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Mar 2022 15:43:08 -0000 Tested powerpc64le-linux, pushed to trunk, -- >8 -- 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. --- libstdc++-v3/include/std/any | 4 ++-- libstdc++-v3/testsuite/20_util/any/cons/104242.cc | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 libstdc++-v3/testsuite/20_util/any/cons/104242.cc diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any index bdad76239b4..a6770e8f235 100644 --- a/libstdc++-v3/include/std/any +++ b/libstdc++-v3/include/std/any @@ -185,8 +185,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); -- 2.34.1