mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 03:15:32 +00:00
Add move assignment operator and move constructor for the ESM::Variant
This commit is contained in:
parent
4db2f79a3c
commit
4d48c81998
2 changed files with 23 additions and 0 deletions
|
@ -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…
Reference in a new issue