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 A54363858D33 for ; Sat, 23 Mar 2024 11:09:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A54363858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A54363858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711192197; cv=none; b=VfkJaTM1D31kLivoRS5jIB6GNXnfF8Z02eL9q5Gw1udBBnpIuM3AeaFENRwwVhdUfbZrXmhDPQbz0WZa1sRir60OqthcYiwIwJ1QTB04uSk7CYPUNgO9NP3h1CcVjCOeedK5O4Y8Bkp/GnkXxBLrwFCSeEvuXdEDc804FvQs9YM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711192197; c=relaxed/simple; bh=m6joc2DvjKyeawmm1HqPqy5JWdrdQQ2g/aC4CS5i29k=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=vxfk9Y8CO5gLXrQwmLg3I/GvxyUtREQSTMJ6xkHD9RpKb42WhpXUO1fOqeNmCNXIsEbELPXB/HZwYh/Y4J7fUzN0F3SxpNFhUWqXug46gLI9AC6yvgLhV3SdhPBFWviuhggnCQKMhrLUQL54nqRBw2HhLt+by362RkpjFJ8s8Qs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711192195; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=L5ZxQIRV5wLYBJW2kzEAIiSG/pZ9inJWw1JeW73Vakw=; b=bf9YwOKWRgoX2Ubysij21DY4CWho4sF3qjUbfbkfDTlq/KNrr5E/5b952dOuMaWQCToKHQ AKElRWKMgupclWxw6cdscwZ+DHxPAL12fpy7K/AR1enxknNztXw87ziu+XTMmP2X5fn0f3 JSoyDMNSvBE6qmr4jhfJQWC8vBDCP2k= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-103-7Z45zYglON25h-555UcuHQ-1; Sat, 23 Mar 2024 07:09:53 -0400 X-MC-Unique: 7Z45zYglON25h-555UcuHQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BE92F185A783; Sat, 23 Mar 2024 11:09:52 +0000 (UTC) Received: from localhost (unknown [10.42.28.188]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C8872022C1D; Sat, 23 Mar 2024 11:09:52 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Add __is_in_place_index_v helper and use it in Date: Sat, 23 Mar 2024 11:09:34 +0000 Message-ID: <20240323110947.426071-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.9 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tested aarch64-linux. Pushed to trunk. -- >8 -- We already have __is_in_place_type_v for in_place_type_t so adding an equivalent for in_place_index_t allows us avoid a class template instantiation for the __not_in_place_tag constraint on the most commonly-used std::variant::variant(T&&) constructor. For in_place_type_t we also have a __is_in_place_type class template defined in terms of the variable template, but that isn't actually used anywhere. I'm not adding an equivalent for the new variable template, because that wouldn't be used either. For GCC 15 we should remove the unused __is_in_place_tag and __is_in_place_type class templates. libstdc++-v3/ChangeLog: * include/bits/utility.h (__is_in_place_index_v): New variable template. * include/std/variant (__not_in_place_tag): Define in terms of variable templates not a class template. --- libstdc++-v3/include/bits/utility.h | 6 ++++++ libstdc++-v3/include/std/variant | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/bits/utility.h b/libstdc++-v3/include/bits/utility.h index 2a741bf7000..9f3b99231b3 100644 --- a/libstdc++-v3/include/bits/utility.h +++ b/libstdc++-v3/include/bits/utility.h @@ -223,6 +223,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template using __is_in_place_type = bool_constant<__is_in_place_type_v<_Tp>>; + template + inline constexpr bool __is_in_place_index_v = false; + + template + inline constexpr bool __is_in_place_index_v> = true; + #endif // C++17 #if _GLIBCXX_USE_BUILTIN_TRAIT(__type_pack_element) diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant index 4b9002e0917..f79d95db7a8 100644 --- a/libstdc++-v3/include/std/variant +++ b/libstdc++-v3/include/std/variant @@ -1414,7 +1414,8 @@ namespace __variant template static constexpr bool __not_in_place_tag - = !__is_in_place_tag<__remove_cvref_t<_Tp>>::value; + = !__is_in_place_type_v<__remove_cvref_t<_Tp>> + && !__is_in_place_index_v<__remove_cvref_t<_Tp>>; public: #if __cpp_concepts -- 2.44.0