forked from TartanLlama/optional
Fix #15
This commit is contained in:
@@ -17,3 +17,18 @@ TEST_CASE("issue 14") {
|
|||||||
REQUIRE(*v == 42);
|
REQUIRE(*v == 42);
|
||||||
REQUIRE((&f->i) == (&*v));
|
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);
|
||||||
|
}
|
@@ -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());
|
construct(std::forward<Opt>(rhs).get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user