[C++] Restore version with correct static_cast, add the same fix for SortedStructs

This commit is contained in:
Alexey Geraskin 2019-08-01 18:10:11 +03:00
parent 34580df089
commit d61f4d6628
1 changed files with 4 additions and 3 deletions

View File

@ -1653,8 +1653,9 @@ class FlatBufferBuilder {
Offset<Vector<const T *>> CreateVectorOfNativeStructs(const S *v, Offset<Vector<const T *>> CreateVectorOfNativeStructs(const S *v,
size_t len) { size_t len) {
extern T Pack(const S &); extern T Pack(const S &);
typedef T (*Pack_t)(const S &);
std::vector<T> vv(len); std::vector<T> vv(len);
std::transform(v, v + len, vv.begin(), Pack); std::transform(v, v + len, vv.begin(), static_cast<Pack_t>(&Pack));
return CreateVectorOfStructs<T>(vv.data(), vv.size()); return CreateVectorOfStructs<T>(vv.data(), vv.size());
} }
@ -1792,8 +1793,8 @@ class FlatBufferBuilder {
extern T Pack(const S &); extern T Pack(const S &);
typedef T (*Pack_t)(const S &); typedef T (*Pack_t)(const S &);
std::vector<T> vv(len); std::vector<T> vv(len);
std::transform(v, v + len, vv.begin(), static_cast<Pack_t&>(Pack)); std::transform(v, v + len, vv.begin(), static_cast<Pack_t>(&Pack));
return CreateVectorOfSortedStructs<T>(vv, len); return CreateVectorOfSortedStructs<T>(vv.data(), vv.size());
} }
/// @cond FLATBUFFERS_INTERNAL /// @cond FLATBUFFERS_INTERNAL