Add move assignment operator and move constructor for the ESM::Variant

pull/593/head
Andrei Kortunov 4 years ago
parent 4db2f79a3c
commit 4d48c81998

@ -62,10 +62,31 @@ ESM::Variant& ESM::Variant::operator= (const Variant& variant)
return *this;
}
ESM::Variant& ESM::Variant::operator= (Variant&& variant)
{
if (&variant!=this)
{
delete mData;
mType = variant.mType;
mData = variant.mData;
variant.mData = nullptr;
}
return *this;
}
ESM::Variant::Variant (const Variant& variant)
: mType (variant.mType), mData (variant.mData ? variant.mData->clone() : nullptr)
{}
ESM::Variant::Variant(Variant&& variant)
: mType (variant.mType), mData (variant.mData)
{
variant.mData = nullptr;
}
ESM::VarType ESM::Variant::getType() const
{
return mType;

@ -46,8 +46,10 @@ namespace ESM
~Variant();
Variant& operator= (const Variant& variant);
Variant& operator= (Variant && variant);
Variant (const Variant& variant);
Variant (Variant&& variant);
VarType getType() const;

Loading…
Cancel
Save