This commit is contained in:
Simon Brand
2018-10-12 13:34:03 +01:00
parent b53059c63d
commit 3449fbc904
2 changed files with 16 additions and 1 deletions

View File

@@ -17,3 +17,18 @@ TEST_CASE("issue 14") {
REQUIRE(*v == 42);
REQUIRE((&f->i) == (&*v));
}
struct fail_on_copy_self {
int value;
fail_on_copy_self(int v) : value(v) {}
fail_on_copy_self(const fail_on_copy_self& other) : value(other.value) {
REQUIRE(&other != this);
}
};
TEST_CASE("issue 15") {
tl::optional<fail_on_copy_self> o = fail_on_copy_self(42);
o = o;
REQUIRE(o->value == 42);
}

View File

@@ -424,7 +424,7 @@ template <class T> struct optional_operations_base : optional_storage_base<T> {
}
}
if (rhs.has_value()) {
else if (rhs.has_value()) {
construct(std::forward<Opt>(rhs).get());
}
}