diff --git a/include/tl/expected.hpp b/include/tl/expected.hpp index b892923..65fce1f 100644 --- a/include/tl/expected.hpp +++ b/include/tl/expected.hpp @@ -825,7 +825,7 @@ struct expected_operations_base : expected_storage_base { if (rhs.m_has_val) { get() = std::forward(rhs).get(); } else { - destroy_val(); + destroy_val(); construct_error(std::forward(rhs).geterr()); } } else { @@ -858,7 +858,7 @@ struct expected_operations_base : expected_storage_base { #endif TL_EXPECTED_11_CONSTEXPR void destroy_val() { - get().~T(); + get().~T(); } }; @@ -913,7 +913,7 @@ struct expected_operations_base : expected_storage_base { #endif TL_EXPECTED_11_CONSTEXPR void destroy_val() { - //no-op + //no-op } }; @@ -1837,12 +1837,12 @@ private: void swap_where_only_one_has_value_and_t_is_not_void( expected &rhs, move_constructing_t_can_throw, - t_is_nothrow_move_constructible) { + e_is_nothrow_move_constructible) { auto temp = std::move(rhs.err()); rhs.err().~unexpected_type(); #ifdef TL_EXPECTED_EXCEPTIONS_ENABLED try { - ::new (rhs.valptr()) T(val()); + ::new (rhs.valptr()) T(std::move(val())); val().~T(); ::new (errptr()) unexpected_type(std::move(temp)); std::swap(this->m_has_val, rhs.m_has_val); @@ -1851,7 +1851,7 @@ private: throw; } #else - ::new (rhs.valptr()) T(val()); + ::new (rhs.valptr()) T(std::move(val())); val().~T(); ::new (errptr()) unexpected_type(std::move(temp)); std::swap(this->m_has_val, rhs.m_has_val); diff --git a/tests/bases.cpp b/tests/bases.cpp index 7189307..fe8d6aa 100644 --- a/tests/bases.cpp +++ b/tests/bases.cpp @@ -38,9 +38,9 @@ TEST_CASE("Triviality", "[bases.triviality]") { { struct T { T(const T&){} - T(T&&) {}; - T& operator=(const T&) {} - T& operator=(T&&) {}; + T(T&&) {} + T& operator=(const T&) { return *this; } + T& operator=(T&&) { return *this; } ~T(){} }; REQUIRE(!std::is_trivially_copy_constructible>::value); diff --git a/tests/extensions.cpp b/tests/extensions.cpp index 9670f90..1dfa63b 100644 --- a/tests/extensions.cpp +++ b/tests/extensions.cpp @@ -3,13 +3,15 @@ #define TOKENPASTE(x, y) x##y #define TOKENPASTE2(x, y) TOKENPASTE(x, y) +#undef STATIC_REQUIRE #define STATIC_REQUIRE(e) \ constexpr bool TOKENPASTE2(rqure, __LINE__) = e; \ + (void)TOKENPASTE2(rqure, __LINE__); \ REQUIRE(e); TEST_CASE("Map extensions", "[extensions.map]") { auto mul2 = [](int a) { return a * 2; }; - auto ret_void = [](int a) {}; + auto ret_void = [](int a) { (void)a; }; { tl::expected e = 21; @@ -143,7 +145,7 @@ TEST_CASE("Map extensions", "[extensions.map]") { TEST_CASE("Map error extensions", "[extensions.map_error]") { auto mul2 = [](int a) { return a * 2; }; - auto ret_void = [](int a) {}; + auto ret_void = [](int a) { (void)a; }; { tl::expected e = 21; @@ -252,8 +254,8 @@ TEST_CASE("Map error extensions", "[extensions.map_error]") { } TEST_CASE("And then extensions", "[extensions.and_then]") { - auto succeed = [](int a) { return tl::expected(21 * 2); }; - auto fail = [](int a) { return tl::expected(tl::unexpect, 17); }; + auto succeed = [](int a) { (void)a; return tl::expected(21 * 2); }; + auto fail = [](int a) { (void)a; return tl::expected(tl::unexpect, 17); }; { tl::expected e = 21; @@ -370,11 +372,10 @@ TEST_CASE("And then extensions", "[extensions.and_then]") { TEST_CASE("or_else", "[extensions.or_else]") { using eptr = std::unique_ptr; - auto succeed = [](int a) { return tl::expected(21 * 2); }; - auto succeedptr = [](eptr e) { return tl::expected(21*2);}; - auto fail = [](int a) { return tl::expected(tl::unexpect, 17);}; - auto efail = [](eptr e) { *e = 17;return tl::expected(tl::unexpect, std::move(e));}; - auto failptr = [](eptr e) { return tl::expected(tl::unexpect, std::move(e));}; + auto succeed = [](int a) { (void)a; return tl::expected(21 * 2); }; + auto succeedptr = [](eptr e) { (void)e; return tl::expected(21*2);}; + auto fail = [](int a) { (void)a; return tl::expected(tl::unexpect, 17);}; + auto failptr = [](eptr e) { *e = 17;return tl::expected(tl::unexpect, std::move(e));}; auto failvoid = [](int) {}; auto failvoidptr = [](const eptr&) { /* don't consume */}; auto consumeptr = [](eptr) {}; @@ -439,7 +440,7 @@ TEST_CASE("or_else", "[extensions.or_else]") { { tl::expected e = 21; - auto ret = std::move(e).or_else(efail); + auto ret = std::move(e).or_else(failptr); REQUIRE(ret); REQUIRE(ret == 21); } @@ -569,7 +570,7 @@ TEST_CASE("14", "[issue.14]") { auto res = tl::expected{tl::unexpect, F{}}; res.map_error([](F f) { - + (void)f; }); } diff --git a/tests/issues.cpp b/tests/issues.cpp index c77d06d..4b5c6fc 100644 --- a/tests/issues.cpp +++ b/tests/issues.cpp @@ -15,7 +15,7 @@ TEST_CASE("Issue 1", "[issues.1]") { getInt1(); } tl::expected operation1() { return 42; } -tl::expected operation2(int const val) { return "Bananas"; } +tl::expected operation2(int const val) { (void)val; return "Bananas"; } TEST_CASE("Issue 17", "[issues.17]") { auto const intermediate_result = operation1(); @@ -67,7 +67,7 @@ struct i31{ }; TEST_CASE("Issue 31", "[issues.31]") { const tl::expected a = i31{42}; - a->i; + (void)a->i; tl::expected< void, std::string > result; tl::expected< void, std::string > result2 = result; @@ -77,7 +77,7 @@ TEST_CASE("Issue 31", "[issues.31]") { TEST_CASE("Issue 33", "[issues.33]") { tl::expected res {tl::unexpect, 0}; REQUIRE(!res); - res = res.map_error([](int i) { return 42; }); + res = res.map_error([](int i) { (void)i; return 42; }); REQUIRE(res.error() == 42); }