File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -17,3 +17,18 @@ TEST_CASE("issue 14") {
1717 REQUIRE (*v == 42 );
1818 REQUIRE ((&f->i ) == (&*v));
1919}
20+
21+ struct fail_on_copy_self {
22+ int value;
23+ fail_on_copy_self (int v) : value(v) {}
24+ fail_on_copy_self (const fail_on_copy_self& other) : value(other.value) {
25+ REQUIRE (&other != this );
26+ }
27+ };
28+
29+ TEST_CASE (" issue 15" ) {
30+ tl::optional<fail_on_copy_self> o = fail_on_copy_self (42 );
31+
32+ o = o;
33+ REQUIRE (o->value == 42 );
34+ }
Original file line number Diff line number Diff line change @@ -424,7 +424,7 @@ template <class T> struct optional_operations_base : optional_storage_base<T> {
424424 }
425425 }
426426
427- if (rhs.has_value ()) {
427+ else if (rhs.has_value ()) {
428428 construct (std::forward<Opt>(rhs).get ());
429429 }
430430 }
You can’t perform that action at this time.
0 commit comments