diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-06-06 13:42:35 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-06-06 14:08:48 +0100 |
commit | d8ea0efb037b1cf2e19cecba464d2fd915dff814 (patch) | |
tree | a0ba6e88c5bc44ccd6db478ddd288e0538563ccd /include/o3tl | |
parent | d97fba020b3e33d9f266c4a405fa221d9b84f946 (diff) |
coverity#1409892 silence Operands don't affect result
Change-Id: I283701880ea9e0a8485ef131afc93438c77451e1
Diffstat (limited to 'include/o3tl')
-rw-r--r-- | include/o3tl/strong_int.hxx | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/include/o3tl/strong_int.hxx b/include/o3tl/strong_int.hxx index 738d30f01a8b..2c9177b405e0 100644 --- a/include/o3tl/strong_int.hxx +++ b/include/o3tl/strong_int.hxx @@ -36,37 +36,33 @@ template<typename T1, typename T2> constexpr typename std::enable_if< std::is_signed<T1>::value && std::is_signed<T2>::value, bool>::type isInRange(T2 value) { - const bool ret = value >= std::numeric_limits<T1>::min() - && value <= std::numeric_limits<T1>::max(); - return ret; + return value >= std::numeric_limits<T1>::min() + && value <= std::numeric_limits<T1>::max(); } template<typename T1, typename T2> constexpr typename std::enable_if< std::is_signed<T1>::value && std::is_unsigned<T2>::value, bool>::type isInRange(T2 value) { - const bool ret = value + return value <= static_cast<typename std::make_unsigned<T1>::type>( std::numeric_limits<T1>::max()); - return ret; } template<typename T1, typename T2> constexpr typename std::enable_if< std::is_unsigned<T1>::value && std::is_signed<T2>::value, bool>::type isInRange(T2 value) { - const bool ret = value >= 0 + return value >= 0 && (static_cast<typename std::make_unsigned<T2>::type>(value) <= std::numeric_limits<T1>::max()); - return ret; } template<typename T1, typename T2> constexpr typename std::enable_if< std::is_unsigned<T1>::value && std::is_unsigned<T2>::value, bool>::type isInRange(T2 value) { - const bool ret = value <= std::numeric_limits<T1>::max(); - return ret; + return value <= std::numeric_limits<T1>::max(); } } @@ -93,7 +89,7 @@ public: typename std::enable_if<std::is_integral<T>::value, int>::type = 0): m_value(value) { -#if HAVE_CXX14_CONSTEXPR +#if !defined __COVERITY__ && HAVE_CXX14_CONSTEXPR // catch attempts to pass in out-of-range values early assert(detail::isInRange<UNDERLYING_TYPE>(value) && "out of range"); |