From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 8B3863858D38; Sat, 23 Mar 2024 11:09:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8B3863858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711192155; bh=xtPbapWlhetsM5+xdVd4KWs0d8sE2zoA1IANEgw8/II=; h=From:To:Subject:Date:From; b=AeYDQEqO4tW9imdlNnYSi5y0h5a+fhifOCgTmdfClkDreGrxoREWGzAB1YRFFmWg3 +C2cTnaThHvKu63UVah+TLWuRHcvcDDmQGyjO4wDZzGHkc99yqvNcSkgGPhLhPRXeq TQfvrYjonnx5BaxV4AM7e78H1gAManEYOZVW+klI= 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 r14-9643] libstdc++: Add __is_in_place_index_v helper and use it in X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: f4605c53ea2eeafc13e14dd1ad00a0caf80057e2 X-Git-Newrev: 3763fb8970d7515a4a3be2152604140965303031 Message-Id: <20240323110915.8B3863858D38@sourceware.org> Date: Sat, 23 Mar 2024 11:09:15 +0000 (GMT) List-Id: https://gcc.gnu.org/g:3763fb8970d7515a4a3be2152604140965303031 commit r14-9643-g3763fb8970d7515a4a3be2152604140965303031 Author: Jonathan Wakely Date: Fri Mar 22 11:47:44 2024 +0000 libstdc++: Add __is_in_place_index_v helper and use it in 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. Diff: --- 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