Skip to content

Commit

Permalink
Clean up existing data in move assignment operator
Browse files Browse the repository at this point in the history
  • Loading branch information
dsnopek committed Dec 21, 2023
1 parent 1c19d62 commit a5b7f00
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions binding_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,8 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
f"\tinternal::_call_builtin_constructor(_method_bindings.constructor_{copy_constructor_index}, &opaque, &other);"
)
else:
if builtin_api["has_destructor"]:
result.append("\t_method_bindings.destructor(&opaque);")
result.append("\tstd::swap(opaque, other.opaque);")
result.append("\treturn *this;")
result.append("}")
Expand Down
1 change: 1 addition & 0 deletions src/variant/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ Variant &Variant::operator=(const Variant &other) {
}

Variant &Variant::operator=(Variant &&other) {
clear();
std::swap(opaque, other.opaque);
return *this;
}
Expand Down

0 comments on commit a5b7f00

Please sign in to comment.