aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2019-09-24 15:17:08 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2019-09-24 15:17:08 +0100
commitfe69bee34c645589d3f2a489d7c67c349960410d (patch)
treee2c9b4dff38e581b702245c845001c3b29464a6a
parenta7701dd16103048432ec8051e4773760c0e2cf90 (diff)
downloadgcc-fe69bee34c645589d3f2a489d7c67c349960410d.zip
gcc-fe69bee34c645589d3f2a489d7c67c349960410d.tar.gz
gcc-fe69bee34c645589d3f2a489d7c67c349960410d.tar.bz2
Remove check for impossible condition in std::variant::index()
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
-rw-r--r--libstdc++-v3/ChangeLog2
-rw-r--r--libstdc++-v3/include/std/variant4
2 files changed, 3 insertions, 3 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 64f8618..7daabe5 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -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
diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index c004324..646ef41 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -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);