[C++] Got rid of memset's in constructors (#5938)

* [C++] removed array's memsets from struct parametrized constructor

now POD-typed arrays are zero-initialized
and class-typed arrays are default-initialized

* [C++] memset -> zero/default initialization in default constructor

* [C++] Struct-type and array default initialization

* [C++] Newly generated tests

* [C++] forgotten test

* [C++] curly brace by code style

* [C++] test if memory is 0's after placement new

* [C++] memory leak fix

* [C++] simplifying and non-dynamic memory in test

* [C++] code cleanup

* [C++] disable old-compiler warning

* [C++] windows build fix (try)

* [C++] debug-new win build fix
This commit is contained in:
bakinovsky-m
2020-06-02 03:58:52 +03:00
committed by GitHub
parent 7179a5a8ba
commit 988164f6e1
10 changed files with 188 additions and 85 deletions

View File

@@ -179,8 +179,10 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Vec3 FLATBUFFERS_FINAL_CLASS {
static const flatbuffers::TypeTable *MiniReflectTypeTable() {
return Vec3TypeTable();
}
Vec3() {
memset(static_cast<void *>(this), 0, sizeof(Vec3));
Vec3()
: x_(0),
y_(0),
z_(0) {
}
Vec3(float _x, float _y, float _z)
: x_(flatbuffers::EndianScalar(_x)),