From d61f4d6628cfce530c8b9a4c9e7af368d599f99f Mon Sep 17 00:00:00 2001 From: Alexey Geraskin Date: Thu, 1 Aug 2019 18:10:11 +0300 Subject: [PATCH] [C++] Restore version with correct static_cast, add the same fix for SortedStructs --- include/flatbuffers/flatbuffers.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h index 1a250cd73..9ceb2c3ee 100644 --- a/include/flatbuffers/flatbuffers.h +++ b/include/flatbuffers/flatbuffers.h @@ -1653,8 +1653,9 @@ class FlatBufferBuilder { Offset> CreateVectorOfNativeStructs(const S *v, size_t len) { extern T Pack(const S &); + typedef T (*Pack_t)(const S &); std::vector vv(len); - std::transform(v, v + len, vv.begin(), Pack); + std::transform(v, v + len, vv.begin(), static_cast(&Pack)); return CreateVectorOfStructs(vv.data(), vv.size()); } @@ -1792,8 +1793,8 @@ class FlatBufferBuilder { extern T Pack(const S &); typedef T (*Pack_t)(const S &); std::vector vv(len); - std::transform(v, v + len, vv.begin(), static_cast(Pack)); - return CreateVectorOfSortedStructs(vv, len); + std::transform(v, v + len, vv.begin(), static_cast(&Pack)); + return CreateVectorOfSortedStructs(vv.data(), vv.size()); } /// @cond FLATBUFFERS_INTERNAL