From b20c4d3aada74ea4bd204b03b5045585008294bc Mon Sep 17 00:00:00 2001 From: Stefan F <32997632+stefan301@users.noreply.github.com> Date: Tue, 31 Aug 2021 00:34:42 +0200 Subject: [C++] Add GetMutableSizePrefixedRoot and generate GetMutableSizePrefixedXxx functions (#6815) * flattests_cpp17 doesn't compile with Visual Studio 2017: warning C4100: 'indent': unreferenced formal parameter stringify_util.h(127): error C2220: warning treated as error - no 'object' file generated stringify_util.h(127): warning C4100: 'indent': unreferenced formal parameter stringify_util.h(85): warning C4100: 'indent': unreferenced formal parameter stringify_util.h(85): warning C4100: 'fbs': unreferenced formal parameter * [C++] Add GetMutableSizePrefixedRoot() and generate a GetMutableSizePrefixed function When using the mutable API together with size prefixed buffers these functions should be present. * clang-format * Cleanup branch for PR Revert "flattests_cpp17 doesn't compile with Visual Studio 2017: warning C4100: 'indent': unreferenced formal parameter" This reverts commit a92055203e3c26b69df4896d6babd7714539307a. --- include/flatbuffers/flatbuffers.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h index 273d5091..23229982 100644 --- a/include/flatbuffers/flatbuffers.h +++ b/include/flatbuffers/flatbuffers.h @@ -2327,6 +2327,11 @@ template T *GetMutableRoot(void *buf) { EndianScalar(*reinterpret_cast(buf))); } +template T *GetMutableSizePrefixedRoot(void *buf) { + return GetMutableRoot(reinterpret_cast(buf) + + sizeof(uoffset_t)); +} + template const T *GetRoot(const void *buf) { return GetMutableRoot(const_cast(buf)); } -- cgit v1.2.3