We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a354f41 commit 333ac2bCopy full SHA for 333ac2b
src/utils/optional.hpp
@@ -73,10 +73,12 @@ namespace detail {
73
optional& operator=(optional&& other)
74
noexcept(std::is_nothrow_move_assignable<value_type>::value && std::is_nothrow_move_constructible<value_type>::value)
75
{
76
- reset();
77
- if(other.holds_value) {
78
- new (static_cast<void*>(std::addressof(uvalue))) value_type(std::move(other.uvalue));
79
- holds_value = true;
+ if (this != &other) {
+ reset();
+ if (other.holds_value) {
+ new (static_cast<void*>(std::addressof(uvalue))) value_type(std::move(other.uvalue));
80
+ holds_value = true;
81
+ }
82
}
83
return *this;
84
0 commit comments