diff options
Diffstat (limited to 'test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp')
-rw-r--r-- | test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp b/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp index 27d8480d10cfe..a2c9df6b4a22e 100644 --- a/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp @@ -11,6 +11,7 @@ #include <bitset> #include <algorithm> +#include <type_traits> #include <climits> #include <cassert> @@ -18,8 +19,9 @@ template <std::size_t N> void test_to_ullong() { const std::size_t M = sizeof(unsigned long long) * CHAR_BIT < N ? sizeof(unsigned long long) * CHAR_BIT : N; - const std::size_t X = M == 0 ? sizeof(unsigned long long) * CHAR_BIT - 1 : sizeof(unsigned long long) * CHAR_BIT - M; - const unsigned long long max = M == 0 ? 0 : (unsigned long long)(-1) >> X; + const bool is_M_zero = std::integral_constant<bool, M == 0>::value; // avoid compiler warnings + const std::size_t X = is_M_zero ? sizeof(unsigned long long) * CHAR_BIT - 1 : sizeof(unsigned long long) * CHAR_BIT - M; + const unsigned long long max = is_M_zero ? 0 : (unsigned long long)(-1) >> X; unsigned long long tests[] = {0, std::min<unsigned long long>(1, max), std::min<unsigned long long>(2, max), |