Remove check for impossible condition in std::variant::index()
authorJonathan Wakely <jwakely@redhat.com>
Tue, 24 Sep 2019 14:17:08 +0000 (15:17 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Tue, 24 Sep 2019 14:17:08 +0000 (15:17 +0100)
The __index_type is only ever unsigned char or unsigned short, so not
the same type as size_t.

* include/std/variant (variant::index()): Remove impossible case.

From-SVN: r276100

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/variant

index 64f8618fc45a9cec53f95b2abd6a64c889c737a8..7daabe5b601038f0b21bf764d5b6d3f03d4f0b59 100644 (file)
@@ -1,5 +1,7 @@
 2019-09-24  Jonathan Wakely  <jwakely@redhat.com>
 
+       * include/std/variant (variant::index()): Remove impossible case.
+
        PR libstdc++/91871
        * testsuite/util/testsuite_hooks.h
        (conversion::iterator_to_const_iterator()): Do not return an invalid
index c0043243ec29a0162df46a725440aa573333d975..646ef416272f9837065c2a544497d1b39165823e 100644 (file)
@@ -1520,9 +1520,7 @@ namespace __variant
       constexpr size_t index() const noexcept
       {
        using __index_type = typename _Base::__index_type;
-       if constexpr (is_same_v<__index_type, size_t>)
-         return this->_M_index;
-       else if constexpr (__detail::__variant::__never_valueless<_Types...>())
+       if constexpr (__detail::__variant::__never_valueless<_Types...>())
          return this->_M_index;
        else if constexpr (sizeof...(_Types) <= __index_type(-1) / 2)
          return make_signed_t<__index_type>(this->_M_index);