[gcc r13-8021] libstdc++: Remove non-void static assertions in variant's std::get [PR111172]

Jonathan Wakely redi@gcc.gnu.org
Thu Nov 9 08:09:40 GMT 2023


https://gcc.gnu.org/g:9847a4e9f025e66bfd09e0174e8bd32aa01939af

commit r13-8021-g9847a4e9f025e66bfd09e0174e8bd32aa01939af
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Sep 12 21:28:38 2023 +0100

    libstdc++: Remove non-void static assertions in variant's std::get [PR111172]
    
    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.
    
    (cherry picked from commit d19bdf8874059457fdfe50a9e14dad8f8b8cecbb)

Diff:
---
 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 90e86b7c61b..a31b7e77238 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -1151,7 +1151,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);
     }
@@ -1162,7 +1161,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));
     }
@@ -1173,7 +1171,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);
     }
@@ -1184,7 +1181,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));
     }


More information about the Libstdc++-cvs mailing list