Commit 17c5f89d authored by Andrei Lebedev's avatar Andrei Lebedev Committed by Wouter van Oortmerssen

Fixed move constructor in generated union class (#4192)

* Fixed move constructor in generated union class

* Removed delegating constructor
parent 695d2618
......@@ -75,7 +75,8 @@ struct EquipmentUnion {
EquipmentUnion() : type(Equipment_NONE), table(nullptr) {}
EquipmentUnion(EquipmentUnion&& u):
type(std::move(u.type)), table(std::move(u.table)) {}
type(Equipment_NONE), table(nullptr)
{ std::swap(type, u.type); std::swap(table, u.table); }
EquipmentUnion(const EquipmentUnion &);
EquipmentUnion &operator=(const EquipmentUnion &);
~EquipmentUnion() { Reset(); }
......
......@@ -652,7 +652,8 @@ class CppGenerator : public BaseGenerator {
code_ += "";
code_ += " {{NAME}}Union() : type({{NONE}}), table(nullptr) {}";
code_ += " {{NAME}}Union({{NAME}}Union&& u):";
code_ += " type(std::move(u.type)), table(std::move(u.table)) {}";
code_ += " type({{NONE}}), table(nullptr)";
code_ += " { std::swap(type, u.type); std::swap(table, u.table); }";
code_ += " {{NAME}}Union(const {{NAME}}Union &);";
code_ += " {{NAME}}Union &operator=(const {{NAME}}Union &);";
code_ += " ~{{NAME}}Union() { Reset(); }";
......
......@@ -104,7 +104,8 @@ struct AnyUnion {
AnyUnion() : type(Any_NONE), table(nullptr) {}
AnyUnion(AnyUnion&& u):
type(std::move(u.type)), table(std::move(u.table)) {}
type(Any_NONE), table(nullptr)
{ std::swap(type, u.type); std::swap(table, u.table); }
AnyUnion(const AnyUnion &);
AnyUnion &operator=(const AnyUnion &);
~AnyUnion() { Reset(); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment