mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-27 06:52:18 +00:00
[C++] Switch flatc to --cpp-std c++11 C++ code generator (#6306)
Prior to this commit the default C++ code generator was `c++0x`. A code generated with `c++0x` code-gen might have a vulnerability (undefined behavior) connected evolution of enums in a schema. This UB could break the backward compatibility if previously generated code casts an unknown enumerator to enum type that knows nothing about future enumerators added to the schema. The main differences between `c++0x` and `c++11`: - generated enums use explicitly declared underlying type; - generated object-API tables don't declare default ctor() explicitly, instead of it default data member initializers are generated. Please use `flatc --cpp-std c++0x` option for backward compatibility with old compilers.
This commit is contained in:
@@ -264,9 +264,7 @@ inline bool operator!=(const ArrayStruct &lhs, const ArrayStruct &rhs) {
|
||||
|
||||
struct ArrayTableT : public flatbuffers::NativeTable {
|
||||
typedef ArrayTable TableType;
|
||||
flatbuffers::unique_ptr<MyGame::Example::ArrayStruct> a;
|
||||
ArrayTableT() {
|
||||
}
|
||||
flatbuffers::unique_ptr<MyGame::Example::ArrayStruct> a{};
|
||||
};
|
||||
|
||||
inline bool operator==(const ArrayTableT &lhs, const ArrayTableT &rhs) {
|
||||
@@ -333,7 +331,7 @@ inline flatbuffers::Offset<ArrayTable> CreateArrayTable(
|
||||
flatbuffers::Offset<ArrayTable> CreateArrayTable(flatbuffers::FlatBufferBuilder &_fbb, const ArrayTableT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);
|
||||
|
||||
inline ArrayTableT *ArrayTable::UnPack(const flatbuffers::resolver_function_t *_resolver) const {
|
||||
flatbuffers::unique_ptr<MyGame::Example::ArrayTableT> _o = flatbuffers::unique_ptr<MyGame::Example::ArrayTableT>(new ArrayTableT());
|
||||
auto _o = std::unique_ptr<ArrayTableT>(new ArrayTableT());
|
||||
UnPackTo(_o.get(), _resolver);
|
||||
return _o.release();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user