[C++] Using calculated fields_number for field_names size (#6769)

* using already defined "fields_number" in "field_names" size calculation

* tests

* forgotten test
This commit is contained in:
bakinovsky-m
2021-08-05 21:41:49 +03:00
committed by GitHub
parent 909ce970ae
commit 5d77820b34
4 changed files with 33 additions and 39 deletions

View File

@@ -639,7 +639,8 @@ struct ScalarStuff::Traits {
static auto constexpr Create = CreateScalarStuff;
static constexpr auto name = "ScalarStuff";
static constexpr auto fully_qualified_name = "optional_scalars.ScalarStuff";
static constexpr std::array<const char *, 36> field_names = {
static constexpr size_t fields_number = 36;
static constexpr std::array<const char *, fields_number> field_names = {
"just_i8",
"maybe_i8",
"default_i8",
@@ -679,7 +680,6 @@ struct ScalarStuff::Traits {
};
template<size_t Index>
using FieldType = decltype(std::declval<type>().get_field<Index>());
static constexpr size_t fields_number = 36;
};
flatbuffers::Offset<ScalarStuff> CreateScalarStuff(flatbuffers::FlatBufferBuilder &_fbb, const ScalarStuffT *_o, const flatbuffers::rehasher_function_t *_rehasher = nullptr);