public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed] libstdc++: Remove non-void static assertions in variant's std::get [PR111172]
Date: Fri, 15 Sep 2023 10:26:48 +0100	[thread overview]
Message-ID: <20230915092737.2192232-1-jwakely@redhat.com> (raw)

Tested x86_64-linux. Pushed to trunk.

This would be safe to backport and slightly improve compile times.

-- >8 --

A void template argument would cause a substitution failure when trying
to form a reference for the return type, so the function body would
never be instantiated.

libstdc++-v3/ChangeLog:

	PR libstdc++/111172
	* include/std/variant (get<T>): Remove !is_void static
	assertions.
---
 libstdc++-v3/include/std/variant | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index 7cb7c3b1d4d..36eec8d829b 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -1123,7 +1123,6 @@ namespace __variant
     {
       static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>,
 		    "T must occur exactly once in alternatives");
-      static_assert(!is_void_v<_Tp>, "_Tp must not be void");
       constexpr size_t __n = std::__find_uniq_type_in_pack<_Tp, _Types...>();
       return std::get<__n>(__v);
     }
@@ -1134,7 +1133,6 @@ namespace __variant
     {
       static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>,
 		    "T must occur exactly once in alternatives");
-      static_assert(!is_void_v<_Tp>, "_Tp must not be void");
       constexpr size_t __n = std::__find_uniq_type_in_pack<_Tp, _Types...>();
       return std::get<__n>(std::move(__v));
     }
@@ -1145,7 +1143,6 @@ namespace __variant
     {
       static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>,
 		    "T must occur exactly once in alternatives");
-      static_assert(!is_void_v<_Tp>, "_Tp must not be void");
       constexpr size_t __n = std::__find_uniq_type_in_pack<_Tp, _Types...>();
       return std::get<__n>(__v);
     }
@@ -1156,7 +1153,6 @@ namespace __variant
     {
       static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>,
 		    "T must occur exactly once in alternatives");
-      static_assert(!is_void_v<_Tp>, "_Tp must not be void");
       constexpr size_t __n = std::__find_uniq_type_in_pack<_Tp, _Types...>();
       return std::get<__n>(std::move(__v));
     }
-- 
2.41.0


                 reply	other threads:[~2023-09-15  9:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230915092737.2192232-1-jwakely@redhat.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).