diff --git a/include/tl/optional.hpp b/include/tl/optional.hpp index 4d41e54..a49e4c8 100644 --- a/include/tl/optional.hpp +++ b/include/tl/optional.hpp @@ -452,7 +452,8 @@ struct optional_copy_base : optional_operations_base { using optional_operations_base::optional_operations_base; optional_copy_base() = default; - optional_copy_base(const optional_copy_base &rhs) { + optional_copy_base(const optional_copy_base &rhs) + : optional_operations_base() { if (rhs.has_value()) { this->construct(rhs.get()); } else { diff --git a/tests/extensions.cpp b/tests/extensions.cpp index a5d6352..1f8d3d3 100644 --- a/tests/extensions.cpp +++ b/tests/extensions.cpp @@ -49,7 +49,7 @@ TEST_CASE("Monadic operations", "[monadic]") { // test void return tl::optional o7 = 40; - auto f7 = [](const int &i) { return; }; + auto f7 = [](const int&) { return; }; auto o7r = o7.map(f7); STATIC_REQUIRE( (std::is_same>::value)); @@ -188,7 +188,7 @@ TEST_CASE("Monadic operations", "[monadic]") { // test void return tl::optional o7 = 40; - auto f7 = [](const int& i) { return; }; + auto f7 = [](const int&) { return; }; auto o7r = o7.transform(f7); STATIC_REQUIRE( (std::is_same>::value)); @@ -295,25 +295,25 @@ TEST_CASE("Monadic operations", "[monadic]") { // lhs is empty tl::optional o1; - auto o1r = o1.and_then([](int i) { return tl::optional{42}; }); + auto o1r = o1.and_then([](int) { return tl::optional{42.f}; }); STATIC_REQUIRE((std::is_same>::value)); REQUIRE(!o1r); // lhs has value tl::optional o2 = 12; - auto o2r = o2.and_then([](int i) { return tl::optional{42}; }); + auto o2r = o2.and_then([](int) { return tl::optional{42.f}; }); STATIC_REQUIRE((std::is_same>::value)); REQUIRE(o2r.value() == 42.f); // lhs is empty, rhs returns empty tl::optional o3; - auto o3r = o3.and_then([](int i) { return tl::optional{}; }); + auto o3r = o3.and_then([](int) { return tl::optional{}; }); STATIC_REQUIRE((std::is_same>::value)); REQUIRE(!o3r); // rhs returns empty tl::optional o4 = 12; - auto o4r = o4.and_then([](int i) { return tl::optional{}; }); + auto o4r = o4.and_then([](int) { return tl::optional{}; }); STATIC_REQUIRE((std::is_same>::value)); REQUIRE(!o4r); @@ -345,38 +345,38 @@ TEST_CASE("Monadic operations", "[monadic]") { // test each overload in turn tl::optional o8 = 42; - auto o8r = o8.and_then([](int i) { return tl::make_optional(42); }); + auto o8r = o8.and_then([](int) { return tl::make_optional(42); }); REQUIRE(*o8r == 42); tl::optional o9 = 42; auto o9r = - std::move(o9).and_then([](int i) { return tl::make_optional(42); }); + std::move(o9).and_then([](int) { return tl::make_optional(42); }); REQUIRE(*o9r == 42); const tl::optional o10 = 42; - auto o10r = o10.and_then([](int i) { return tl::make_optional(42); }); + auto o10r = o10.and_then([](int) { return tl::make_optional(42); }); REQUIRE(*o10r == 42); const tl::optional o11 = 42; auto o11r = - std::move(o11).and_then([](int i) { return tl::make_optional(42); }); + std::move(o11).and_then([](int) { return tl::make_optional(42); }); REQUIRE(*o11r == 42); tl::optional o16 = tl::nullopt; - auto o16r = o16.and_then([](int i) { return tl::make_optional(42); }); + auto o16r = o16.and_then([](int) { return tl::make_optional(42); }); REQUIRE(!o16r); tl::optional o17 = tl::nullopt; auto o17r = - std::move(o17).and_then([](int i) { return tl::make_optional(42); }); + std::move(o17).and_then([](int) { return tl::make_optional(42); }); REQUIRE(!o17r); const tl::optional o18 = tl::nullopt; - auto o18r = o18.and_then([](int i) { return tl::make_optional(42); }); + auto o18r = o18.and_then([](int) { return tl::make_optional(42); }); REQUIRE(!o18r); const tl::optional o19 = tl::nullopt; - auto o19r = std::move(o19).and_then([](int i) { return tl::make_optional(42); }); + auto o19r = std::move(o19).and_then([](int) { return tl::make_optional(42); }); REQUIRE(!o19r); int i = 3; @@ -487,5 +487,6 @@ TEST_CASE("Monadic operations", "[monadic]") { SECTION("Issue #2") { tl::optional f = foo{}; auto x = f.and_then(overloaded{}); + (void)x; } -}; +} diff --git a/tests/issues.cpp b/tests/issues.cpp index d5672a3..fdf7d7e 100644 --- a/tests/issues.cpp +++ b/tests/issues.cpp @@ -24,6 +24,7 @@ struct fail_on_copy_self { fail_on_copy_self(const fail_on_copy_self& other) : value(other.value) { REQUIRE(&other != this); } + fail_on_copy_self& operator=(const fail_on_copy_self&) = default; }; TEST_CASE("issue 15") {