Fixed issue #129 (#131)

+ Fixed unused variable warning
+ Added a `std::move` to avoid calling copy-assignment operator on non-copyable types

Co-authored-by: andy-byers <andrew.byers@utdallas.edu>
This commit is contained in:
Andrew Byers
2023-02-15 15:54:16 +00:00
committed by GitHub
co-authored by andy-byers
parent 79a2068c9a
commit f5e6e9aeed
3 changed files with 16 additions and 1 deletions
+6
View File
@@ -14,6 +14,8 @@ struct canthrow_move {
};
bool should_throw = false;
#ifdef TL_EXPECTED_EXCEPTIONS_ENABLED
struct willthrow_move {
willthrow_move(std::string i) : i(i) {}
willthrow_move(willthrow_move const &) = default;
@@ -24,6 +26,8 @@ struct willthrow_move {
willthrow_move &operator=(willthrow_move &&) = default;
std::string i;
};
#endif // TL_EXPECTED_EXCEPTIONS_ENABLED
static_assert(tl::detail::is_swappable<no_throw>::value, "");
template <class T1, class T2> void swap_test() {
@@ -79,6 +83,7 @@ template <class T1, class T2> void swap_test() {
REQUIRE(b.error().i == s1);
}
#ifdef TL_EXPECTED_EXCEPTIONS_ENABLED
TEST_CASE("swap") {
swap_test<no_throw, no_throw>();
@@ -99,3 +104,4 @@ TEST_CASE("swap") {
REQUIRE(a->i == s1);
REQUIRE(b.error().i == s2);
}
#endif // TL_EXPECTED_EXCEPTIONS_ENABLED