From 9d45a640363a49e701e5bf7c04c740ef4edaa3c0 Mon Sep 17 00:00:00 2001 From: Derek Bailey Date: Tue, 19 Apr 2022 14:35:20 -0700 Subject: [PATCH] more google merge fixes --- include/flatbuffers/flatbuffer_builder.h | 2 +- include/flatbuffers/vector.h | 1 + src/idl_gen_cpp.cpp | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/flatbuffers/flatbuffer_builder.h b/include/flatbuffers/flatbuffer_builder.h index 9cc294d1e..aa02f50d8 100644 --- a/include/flatbuffers/flatbuffer_builder.h +++ b/include/flatbuffers/flatbuffer_builder.h @@ -739,7 +739,7 @@ class FlatBufferBuilder { /// @return Returns a typed `Offset` into the serialized data indicating /// where the vector is stored. template> + typename Alloc = std::allocator> Offset>> CreateVectorOfStrings( const std::vector &v) { return CreateVectorOfStrings(v.cbegin(), v.cend()); diff --git a/include/flatbuffers/vector.h b/include/flatbuffers/vector.h index f8a5d88e8..c227ddd7a 100644 --- a/include/flatbuffers/vector.h +++ b/include/flatbuffers/vector.h @@ -19,6 +19,7 @@ #include "flatbuffers/base.h" #include "flatbuffers/buffer.h" +#include "flatbuffers/stl_emulation.h" namespace flatbuffers { diff --git a/src/idl_gen_cpp.cpp b/src/idl_gen_cpp.cpp index 4e12f3fff..da28dac48 100644 --- a/src/idl_gen_cpp.cpp +++ b/src/idl_gen_cpp.cpp @@ -3267,7 +3267,8 @@ class CppGenerator : public BaseGenerator { // If set_empty_vectors_to_null option is enabled, for optional fields, // check to see if there actually is any data in _o->field before // attempting to access it. - if (opts_.set_empty_vectors_to_null && !field.IsRequired()) { + if (field.attributes.Lookup("nested_flatbuffer") || + (opts_.set_empty_vectors_to_null && !field.IsRequired())) { code = value + ".size() ? " + code + " : 0"; } break;