Skip to content

Commit f3705fe

Browse files
committed
Fix various compile warnings
1 parent aa10eef commit f3705fe

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

include/tl/optional.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,8 @@ struct optional_copy_base<T, false> : optional_operations_base<T> {
452452
using optional_operations_base<T>::optional_operations_base;
453453

454454
optional_copy_base() = default;
455-
optional_copy_base(const optional_copy_base &rhs) {
455+
optional_copy_base(const optional_copy_base &rhs)
456+
: optional_operations_base<T>() {
456457
if (rhs.has_value()) {
457458
this->construct(rhs.get());
458459
} else {

tests/extensions.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ TEST_CASE("Monadic operations", "[monadic]") {
4949

5050
// test void return
5151
tl::optional<int> o7 = 40;
52-
auto f7 = [](const int &i) { return; };
52+
auto f7 = [](const int&) { return; };
5353
auto o7r = o7.map(f7);
5454
STATIC_REQUIRE(
5555
(std::is_same<decltype(o7r), tl::optional<tl::monostate>>::value));
@@ -188,7 +188,7 @@ TEST_CASE("Monadic operations", "[monadic]") {
188188

189189
// test void return
190190
tl::optional<int> o7 = 40;
191-
auto f7 = [](const int& i) { return; };
191+
auto f7 = [](const int&) { return; };
192192
auto o7r = o7.transform(f7);
193193
STATIC_REQUIRE(
194194
(std::is_same<decltype(o7r), tl::optional<tl::monostate>>::value));
@@ -295,25 +295,25 @@ TEST_CASE("Monadic operations", "[monadic]") {
295295

296296
// lhs is empty
297297
tl::optional<int> o1;
298-
auto o1r = o1.and_then([](int i) { return tl::optional<float>{42}; });
298+
auto o1r = o1.and_then([](int) { return tl::optional<float>{42.f}; });
299299
STATIC_REQUIRE((std::is_same<decltype(o1r), tl::optional<float>>::value));
300300
REQUIRE(!o1r);
301301

302302
// lhs has value
303303
tl::optional<int> o2 = 12;
304-
auto o2r = o2.and_then([](int i) { return tl::optional<float>{42}; });
304+
auto o2r = o2.and_then([](int) { return tl::optional<float>{42.f}; });
305305
STATIC_REQUIRE((std::is_same<decltype(o2r), tl::optional<float>>::value));
306306
REQUIRE(o2r.value() == 42.f);
307307

308308
// lhs is empty, rhs returns empty
309309
tl::optional<int> o3;
310-
auto o3r = o3.and_then([](int i) { return tl::optional<float>{}; });
310+
auto o3r = o3.and_then([](int) { return tl::optional<float>{}; });
311311
STATIC_REQUIRE((std::is_same<decltype(o3r), tl::optional<float>>::value));
312312
REQUIRE(!o3r);
313313

314314
// rhs returns empty
315315
tl::optional<int> o4 = 12;
316-
auto o4r = o4.and_then([](int i) { return tl::optional<float>{}; });
316+
auto o4r = o4.and_then([](int) { return tl::optional<float>{}; });
317317
STATIC_REQUIRE((std::is_same<decltype(o4r), tl::optional<float>>::value));
318318
REQUIRE(!o4r);
319319

@@ -345,38 +345,38 @@ TEST_CASE("Monadic operations", "[monadic]") {
345345

346346
// test each overload in turn
347347
tl::optional<int> o8 = 42;
348-
auto o8r = o8.and_then([](int i) { return tl::make_optional(42); });
348+
auto o8r = o8.and_then([](int) { return tl::make_optional(42); });
349349
REQUIRE(*o8r == 42);
350350

351351
tl::optional<int> o9 = 42;
352352
auto o9r =
353-
std::move(o9).and_then([](int i) { return tl::make_optional(42); });
353+
std::move(o9).and_then([](int) { return tl::make_optional(42); });
354354
REQUIRE(*o9r == 42);
355355

356356
const tl::optional<int> o10 = 42;
357-
auto o10r = o10.and_then([](int i) { return tl::make_optional(42); });
357+
auto o10r = o10.and_then([](int) { return tl::make_optional(42); });
358358
REQUIRE(*o10r == 42);
359359

360360
const tl::optional<int> o11 = 42;
361361
auto o11r =
362-
std::move(o11).and_then([](int i) { return tl::make_optional(42); });
362+
std::move(o11).and_then([](int) { return tl::make_optional(42); });
363363
REQUIRE(*o11r == 42);
364364

365365
tl::optional<int> o16 = tl::nullopt;
366-
auto o16r = o16.and_then([](int i) { return tl::make_optional(42); });
366+
auto o16r = o16.and_then([](int) { return tl::make_optional(42); });
367367
REQUIRE(!o16r);
368368

369369
tl::optional<int> o17 = tl::nullopt;
370370
auto o17r =
371-
std::move(o17).and_then([](int i) { return tl::make_optional(42); });
371+
std::move(o17).and_then([](int) { return tl::make_optional(42); });
372372
REQUIRE(!o17r);
373373

374374
const tl::optional<int> o18 = tl::nullopt;
375-
auto o18r = o18.and_then([](int i) { return tl::make_optional(42); });
375+
auto o18r = o18.and_then([](int) { return tl::make_optional(42); });
376376
REQUIRE(!o18r);
377377

378378
const tl::optional<int> o19 = tl::nullopt;
379-
auto o19r = std::move(o19).and_then([](int i) { return tl::make_optional(42); });
379+
auto o19r = std::move(o19).and_then([](int) { return tl::make_optional(42); });
380380
REQUIRE(!o19r);
381381

382382
int i = 3;
@@ -487,5 +487,6 @@ TEST_CASE("Monadic operations", "[monadic]") {
487487
SECTION("Issue #2") {
488488
tl::optional<foo> f = foo{};
489489
auto x = f.and_then(overloaded{});
490+
(void)x;
490491
}
491-
};
492+
}

tests/issues.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ struct fail_on_copy_self {
2424
fail_on_copy_self(const fail_on_copy_self& other) : value(other.value) {
2525
REQUIRE(&other != this);
2626
}
27+
fail_on_copy_self& operator=(const fail_on_copy_self&) = default;
2728
};
2829

2930
TEST_CASE("issue 15") {

0 commit comments

Comments
 (0)