Skip to content

Commit a401d3f

Browse files
committed
Use std::ignore to fix unused variable warnings
1 parent 9f44298 commit a401d3f

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

benchmark/benchmark_concur.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <future>
44
#include <atomic>
55
#include <vector>
6+
#include <tuple>
67

78
#include "benchmark/benchmark.h"
89

@@ -18,18 +19,18 @@ void concur_queue_rtt(benchmark::State &state) {
1819
for (std::int64_t i = 0; !stop.load(std::memory_order_relaxed); ++i) {
1920
std::int64_t n {};
2021
while (!que[0].pop(n)) ;
21-
(void)que[1].push(i);
22+
std::ignore = que[1].push(i);
2223
}
2324
});
2425

2526
for (auto _ : state) {
26-
(void)que[0].push(0);
27+
std::ignore = que[0].push(0);
2728
std::int64_t n {};
2829
while (!que[1].pop(n)) ;
2930
}
3031

3132
stop = true;
32-
(void)que[0].push(0);
33+
std::ignore = que[0].push(0);
3334
producer.wait();
3435
}
3536

@@ -39,7 +40,7 @@ void concur_queue_1v1(benchmark::State &state) {
3940
std::atomic_bool stop = false;
4041
auto producer = std::async(std::launch::async, [&stop, &que] {
4142
for (std::int64_t i = 0; !stop.load(std::memory_order_relaxed); ++i) {
42-
(void)que.push(i);
43+
std::ignore = que.push(i);
4344
std::this_thread::yield();
4445
}
4546
});
@@ -65,7 +66,7 @@ void concur_queue_NvN(benchmark::State &state) {
6566
prods.resize(state.threads());
6667
auto producer = [] {
6768
for (std::int64_t i = 0; run.load(std::memory_order_relaxed) > 0; ++i) {
68-
(void)que.push(i);
69+
std::ignore = que.push(i);
6970
std::this_thread::yield();
7071
}
7172
};

include/libconcur/data_model.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <atomic>
1010
#include <array>
11+
#include <tuple>
1112
#include <cstddef>
1213
#include <cstdint>
1314

@@ -46,19 +47,19 @@ class data_model {
4647
typename decltype(elements)::size_type i = 0;
4748
LIBIMP_TRY {
4849
for (; i < elements.size(); ++i) {
49-
(void)::LIBIMP::construct<element<value_type>>(&elements[i]);
50+
std::ignore = ::LIBIMP::construct<element<value_type>>(&elements[i]);
5051
}
5152
} LIBIMP_CATCH(...) {
5253
for (decltype(i) k = 0; k < i; ++k) {
53-
(void)::LIBIMP::destroy<element<value_type>>(&elements[k]);
54+
std::ignore = ::LIBIMP::destroy<element<value_type>>(&elements[k]);
5455
}
5556
throw;
5657
}
5758
}
5859

5960
~data() noexcept {
6061
for (auto &elem : this->elements()) {
61-
(void)::LIBIMP::destroy<element<value_type>>(&elem);
62+
std::ignore = ::LIBIMP::destroy<element<value_type>>(&elem);
6263
}
6364
}
6465

@@ -124,7 +125,7 @@ class data_model {
124125
~data_model() noexcept {
125126
if (valid()) {
126127
auto sz = data_->byte_size();
127-
(void)::LIBIMP::destroy<data>(data_);
128+
std::ignore = ::LIBIMP::destroy<data>(data_);
128129
data_allocator_.deallocate(data_, sz);
129130
}
130131
}

0 commit comments

Comments
 (0)