diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h index 7b72319df..e1999f90a 100644 --- a/include/flatbuffers/flatbuffers.h +++ b/include/flatbuffers/flatbuffers.h @@ -649,11 +649,15 @@ class FlatBufferBuilder FLATBUFFERS_FINAL_CLASS { // Specialized version for non-copying use cases. Data to be written later. // After calling this function, GetBufferPointer() can be cast to the // corresponding Vector<> type to write the data (through Data()). - template Offset> CreateUninitializedVector(size_t len) { + uoffset_t CreateUninitializedVector(size_t len, size_t elemsize) { NotNested(); - StartVector(len, sizeof(T)); - buf_.make_space(len * sizeof(T)); - return Offset>(EndVector(len)); + StartVector(len, elemsize); + buf_.make_space(len * elemsize); + return EndVector(len); + } + + template Offset> CreateUninitializedVector(size_t len) { + return CreateUninitializedVector(len, sizeof(T)); } template Offset> CreateVector(const std::vector &v){