Commit b7bfecb4 authored by 水樹素子's avatar 水樹素子 Committed by Wouter van Oortmerssen

Add move constructor to generated union class. (#4167)

* Add move constructor to generated union class.

* Unused default

* Add generated code
parent c7c4bbfc
...@@ -74,6 +74,8 @@ struct EquipmentUnion { ...@@ -74,6 +74,8 @@ struct EquipmentUnion {
flatbuffers::NativeTable *table; flatbuffers::NativeTable *table;
EquipmentUnion() : type(Equipment_NONE), table(nullptr) {} EquipmentUnion() : type(Equipment_NONE), table(nullptr) {}
EquipmentUnion(EquipmentUnion&& u):
type(std::move(u.type)), table(std::move(u.table)) {}
EquipmentUnion(const EquipmentUnion &); EquipmentUnion(const EquipmentUnion &);
EquipmentUnion &operator=(const EquipmentUnion &); EquipmentUnion &operator=(const EquipmentUnion &);
~EquipmentUnion() { Reset(); } ~EquipmentUnion() { Reset(); }
......
...@@ -650,6 +650,8 @@ class CppGenerator : public BaseGenerator { ...@@ -650,6 +650,8 @@ class CppGenerator : public BaseGenerator {
code_ += " flatbuffers::NativeTable *table;"; code_ += " flatbuffers::NativeTable *table;";
code_ += ""; code_ += "";
code_ += " {{NAME}}Union() : type({{NONE}}), table(nullptr) {}"; 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_ += " {{NAME}}Union(const {{NAME}}Union &);"; code_ += " {{NAME}}Union(const {{NAME}}Union &);";
code_ += " {{NAME}}Union &operator=(const {{NAME}}Union &);"; code_ += " {{NAME}}Union &operator=(const {{NAME}}Union &);";
code_ += " ~{{NAME}}Union() { Reset(); }"; code_ += " ~{{NAME}}Union() { Reset(); }";
......
...@@ -103,6 +103,8 @@ struct AnyUnion { ...@@ -103,6 +103,8 @@ struct AnyUnion {
flatbuffers::NativeTable *table; flatbuffers::NativeTable *table;
AnyUnion() : type(Any_NONE), table(nullptr) {} AnyUnion() : type(Any_NONE), table(nullptr) {}
AnyUnion(AnyUnion&& u):
type(std::move(u.type)), table(std::move(u.table)) {}
AnyUnion(const AnyUnion &); AnyUnion(const AnyUnion &);
AnyUnion &operator=(const AnyUnion &); AnyUnion &operator=(const AnyUnion &);
~AnyUnion() { Reset(); } ~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