summaryrefslogtreecommitdiff
path: root/test/std/utilities/template.bitset/bitset.members
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-04-16 16:03:23 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-04-16 16:03:23 +0000
commit0dc0969cd0a732760f0aa79942a04e0eaef297c4 (patch)
tree051bdb57b1ac6ee143f61ddbb47bd0da619f6f0c /test/std/utilities/template.bitset/bitset.members
parent868847c6900e575417c03bced6e562b3af891318 (diff)
Notes
Diffstat (limited to 'test/std/utilities/template.bitset/bitset.members')
-rw-r--r--test/std/utilities/template.bitset/bitset.members/all.pass.cpp4
-rw-r--r--test/std/utilities/template.bitset/bitset.members/any.pass.cpp4
-rw-r--r--test/std/utilities/template.bitset/bitset.members/index.pass.cpp4
-rw-r--r--test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp4
-rw-r--r--test/std/utilities/template.bitset/bitset.members/none.pass.cpp4
-rw-r--r--test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp4
-rw-r--r--test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp6
-rw-r--r--test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp6
8 files changed, 26 insertions, 10 deletions
diff --git a/test/std/utilities/template.bitset/bitset.members/all.pass.cpp b/test/std/utilities/template.bitset/bitset.members/all.pass.cpp
index 5387b733918fe..de1cddb5b1ae8 100644
--- a/test/std/utilities/template.bitset/bitset.members/all.pass.cpp
+++ b/test/std/utilities/template.bitset/bitset.members/all.pass.cpp
@@ -10,6 +10,7 @@
// test bool all() const;
#include <bitset>
+#include <type_traits>
#include <cassert>
template <std::size_t N>
@@ -20,7 +21,8 @@ void test_all()
assert(v.all() == (N == 0));
v.set();
assert(v.all() == true);
- if (N > 1)
+ const bool greater_than_1 = std::integral_constant<bool, (N > 1)>::value; // avoid compiler warnings
+ if (greater_than_1)
{
v[N/2] = false;
assert(v.all() == false);
diff --git a/test/std/utilities/template.bitset/bitset.members/any.pass.cpp b/test/std/utilities/template.bitset/bitset.members/any.pass.cpp
index aa6384a49df1d..7ee83dd074822 100644
--- a/test/std/utilities/template.bitset/bitset.members/any.pass.cpp
+++ b/test/std/utilities/template.bitset/bitset.members/any.pass.cpp
@@ -10,6 +10,7 @@
// test bool any() const;
#include <bitset>
+#include <type_traits>
#include <cassert>
template <std::size_t N>
@@ -20,7 +21,8 @@ void test_any()
assert(v.any() == false);
v.set();
assert(v.any() == (N != 0));
- if (N > 1)
+ const bool greater_than_1 = std::integral_constant<bool, (N > 1)>::value; // avoid compiler warnings
+ if (greater_than_1)
{
v[N/2] = false;
assert(v.any() == true);
diff --git a/test/std/utilities/template.bitset/bitset.members/index.pass.cpp b/test/std/utilities/template.bitset/bitset.members/index.pass.cpp
index 02e58a7890c54..f352475fc1996 100644
--- a/test/std/utilities/template.bitset/bitset.members/index.pass.cpp
+++ b/test/std/utilities/template.bitset/bitset.members/index.pass.cpp
@@ -10,6 +10,7 @@
// test bitset<N>::reference operator[](size_t pos);
#include <bitset>
+#include <type_traits>
#include <cstdlib>
#include <cassert>
@@ -31,7 +32,8 @@ template <std::size_t N>
void test_index_const()
{
std::bitset<N> v1 = make_bitset<N>();
- if (N > 0)
+ const bool greater_than_0 = std::integral_constant<bool, (N > 0)>::value; // avoid compiler warnings
+ if (greater_than_0)
{
assert(v1[N/2] == v1.test(N/2));
typename std::bitset<N>::reference r = v1[N/2];
diff --git a/test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp b/test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp
index 870a504c2d751..fbde54859f19e 100644
--- a/test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp
+++ b/test/std/utilities/template.bitset/bitset.members/index_const.pass.cpp
@@ -10,6 +10,7 @@
// test constexpr bool operator[](size_t pos) const;
#include <bitset>
+#include <type_traits>
#include <cstdlib>
#include <cassert>
@@ -31,7 +32,8 @@ template <std::size_t N>
void test_index_const()
{
const std::bitset<N> v1 = make_bitset<N>();
- if (N > 0)
+ const bool greater_than_0 = std::integral_constant<bool, (N > 0)>::value; // avoid compiler warnings
+ if (greater_than_0)
{
assert(v1[N/2] == v1.test(N/2));
}
diff --git a/test/std/utilities/template.bitset/bitset.members/none.pass.cpp b/test/std/utilities/template.bitset/bitset.members/none.pass.cpp
index b65c636f3c560..1358eaa62d593 100644
--- a/test/std/utilities/template.bitset/bitset.members/none.pass.cpp
+++ b/test/std/utilities/template.bitset/bitset.members/none.pass.cpp
@@ -10,6 +10,7 @@
// test bool none() const;
#include <bitset>
+#include <type_traits>
#include <cassert>
template <std::size_t N>
@@ -20,7 +21,8 @@ void test_none()
assert(v.none() == true);
v.set();
assert(v.none() == (N == 0));
- if (N > 1)
+ const bool greater_than_1 = std::integral_constant<bool, (N > 1)>::value; // avoid compiler warnings
+ if (greater_than_1)
{
v[N/2] = false;
assert(v.none() == false);
diff --git a/test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp b/test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp
index 24761c628c03e..5b7e10d677ee3 100644
--- a/test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp
+++ b/test/std/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp
@@ -13,6 +13,7 @@
// bool operator!=(const bitset<N>& rhs) const;
#include <bitset>
+#include <type_traits>
#include <cstdlib>
#include <cassert>
@@ -36,7 +37,8 @@ void test_equality()
const std::bitset<N> v1 = make_bitset<N>();
std::bitset<N> v2 = v1;
assert(v1 == v2);
- if (N > 0)
+ const bool greater_than_0 = std::integral_constant<bool, (N > 0)>::value; // avoid compiler warnings
+ if (greater_than_0)
{
v2[N/2].flip();
assert(v1 != v2);
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),
diff --git a/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp b/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp
index 3ad1abade9f48..7cabd06e5f322 100644
--- a/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp
+++ b/test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp
@@ -11,6 +11,7 @@
#include <bitset>
#include <algorithm>
+#include <type_traits>
#include <limits>
#include <climits>
#include <cassert>
@@ -19,8 +20,9 @@ template <std::size_t N>
void test_to_ulong()
{
const std::size_t M = sizeof(unsigned long) * CHAR_BIT < N ? sizeof(unsigned long) * CHAR_BIT : N;
- const std::size_t X = M == 0 ? sizeof(unsigned long) * CHAR_BIT - 1 : sizeof(unsigned long) * CHAR_BIT - M;
- const std::size_t max = M == 0 ? 0 : std::size_t(std::numeric_limits<unsigned long>::max()) >> 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) * CHAR_BIT - 1 : sizeof(unsigned long) * CHAR_BIT - M;
+ const std::size_t max = is_M_zero ? 0 : std::size_t(std::numeric_limits<unsigned long>::max()) >> X;
std::size_t tests[] = {0,
std::min<std::size_t>(1, max),
std::min<std::size_t>(2, max),