summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/flatbuffers/flatbuffers.h7
-rw-r--r--samples/monster_generated.h4
-rw-r--r--src/idl_gen_cpp.cpp4
-rw-r--r--tests/monster_test_generated.h4
4 files changed, 16 insertions, 3 deletions
diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h
index 8ea80c89..9fc2236b 100644
--- a/include/flatbuffers/flatbuffers.h
+++ b/include/flatbuffers/flatbuffers.h
@@ -113,6 +113,13 @@
#define FLATBUFFERS_CONSTEXPR
#endif
+#if defined(__GXX_EXPERIMENTAL_CXX0X__) && __GNUC__ * 10 + __GNUC_MINOR__ >= 46 || \
+ defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023026
+ #define FLATBUFFERS_NOEXCEPT noexcept
+#else
+ #define FLATBUFFERS_NOEXCEPT
+#endif
+
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable: 4127) // C4127: conditional expression is constant
diff --git a/samples/monster_generated.h b/samples/monster_generated.h
index 464fc176..05633d96 100644
--- a/samples/monster_generated.h
+++ b/samples/monster_generated.h
@@ -74,11 +74,13 @@ struct EquipmentUnion {
flatbuffers::NativeTable *table;
EquipmentUnion() : type(Equipment_NONE), table(nullptr) {}
- EquipmentUnion(EquipmentUnion&& u):
+ EquipmentUnion(EquipmentUnion&& u) FLATBUFFERS_NOEXCEPT :
type(Equipment_NONE), table(nullptr)
{ std::swap(type, u.type); std::swap(table, u.table); }
EquipmentUnion(const EquipmentUnion &);
EquipmentUnion &operator=(const EquipmentUnion &);
+ EquipmentUnion &operator=(EquipmentUnion &&u) FLATBUFFERS_NOEXCEPT
+ { std::swap(type, u.type); std::swap(table, u.table); return *this; }
~EquipmentUnion() { Reset(); }
void Reset();
diff --git a/src/idl_gen_cpp.cpp b/src/idl_gen_cpp.cpp
index 8977c6b0..521ca8fb 100644
--- a/src/idl_gen_cpp.cpp
+++ b/src/idl_gen_cpp.cpp
@@ -660,11 +660,13 @@ class CppGenerator : public BaseGenerator {
code_ += " flatbuffers::NativeTable *table;";
code_ += "";
code_ += " {{NAME}}Union() : type({{NONE}}), table(nullptr) {}";
- code_ += " {{NAME}}Union({{NAME}}Union&& u):";
+ code_ += " {{NAME}}Union({{NAME}}Union&& u) FLATBUFFERS_NOEXCEPT :";
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 &operator=({{NAME}}Union &&u) FLATBUFFERS_NOEXCEPT";
+ code_ += " { std::swap(type, u.type); std::swap(table, u.table); return *this; }";
code_ += " ~{{NAME}}Union() { Reset(); }";
code_ += "";
code_ += " void Reset();";
diff --git a/tests/monster_test_generated.h b/tests/monster_test_generated.h
index 57966f5f..9fca310b 100644
--- a/tests/monster_test_generated.h
+++ b/tests/monster_test_generated.h
@@ -105,11 +105,13 @@ struct AnyUnion {
flatbuffers::NativeTable *table;
AnyUnion() : type(Any_NONE), table(nullptr) {}
- AnyUnion(AnyUnion&& u):
+ AnyUnion(AnyUnion&& u) FLATBUFFERS_NOEXCEPT :
type(Any_NONE), table(nullptr)
{ std::swap(type, u.type); std::swap(table, u.table); }
AnyUnion(const AnyUnion &);
AnyUnion &operator=(const AnyUnion &);
+ AnyUnion &operator=(AnyUnion &&u) FLATBUFFERS_NOEXCEPT
+ { std::swap(type, u.type); std::swap(table, u.table); return *this; }
~AnyUnion() { Reset(); }
void Reset();