mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-04 12:43:24 +00:00
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:
committed by
Wouter van Oortmerssen
parent
e2c7196ea8
commit
853f7033e0
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user