any: avoid invalid state from assignment operator for non-copyable types

This commit is contained in:
Michele Caini
2021-04-29 10:05:01 +02:00
parent b030df55ee
commit baa9d7d836

View File

@@ -264,7 +264,7 @@ public:
* @return This any object.
*/
basic_any & operator=(const basic_any &other) {
vtable(operation::DTOR, *this, nullptr);
std::exchange(vtable, &basic_vtable<void>)(operation::DTOR, *this, nullptr);
other.vtable(operation::COPY, other, this);
return *this;
}