Remove copy constructor to make flatbuffers struct trivially copyable… (#4476)

* Remove copy constructor to make flatbuffers struct trivially copyable + add tests.

* Add support non c++11 compliant compilers.

* Fix std::trivially_copyiable test for non-C++11 compliant compilers.

* Fix trivially_copyable not part of glibc < 5 even with c++11 switch enabled.
This commit is contained in:
Louis-Paul CORDIER
2017-11-16 19:08:41 +01:00
committed by Wouter van Oortmerssen
parent e2c7196ea8
commit 853f7033e0
3 changed files with 15 additions and 14 deletions

View File

@@ -526,6 +526,18 @@ void SizePrefixedTest() {
TEST_EQ_STR(m->name()->c_str(), "bob");
}
void TriviallyCopyableTest() {
#if __GNUG__ && __GNUC__ < 5
TEST_EQ(__has_trivial_copy(Vec3), true);
#else
#if __cplusplus >= 201103L
TEST_EQ(std::is_trivially_copyable<Vec3>::value, true);
#endif
#endif
}
// example of parsing text straight into a buffer, and generating
// text back from it:
void ParseAndGenerateTextTest() {
@@ -1809,6 +1821,9 @@ int main(int /*argc*/, const char * /*argv*/[]) {
#else
auto &flatbuf = flatbuf1;
#endif // !defined(FLATBUFFERS_CPP98_STL)
TriviallyCopyableTest();
AccessFlatBufferTest(reinterpret_cast<const uint8_t *>(rawbuf.c_str()),
rawbuf.length());
AccessFlatBufferTest(flatbuf.data(), flatbuf.size());