forked from BigfootDev/flatbuffers
explicitly defined std::allocator (#7094)
This commit is contained in:
@@ -42,14 +42,15 @@ inline voffset_t FieldIndexToOffset(voffset_t field_id) {
|
||||
return static_cast<voffset_t>((field_id + fixed_fields) * sizeof(voffset_t));
|
||||
}
|
||||
|
||||
template<typename T, typename Alloc>
|
||||
template<typename T, typename Alloc = std::allocator<T>>
|
||||
const T *data(const std::vector<T, Alloc> &v) {
|
||||
// Eventually the returned pointer gets passed down to memcpy, so
|
||||
// we need it to be non-null to avoid undefined behavior.
|
||||
static uint8_t t;
|
||||
return v.empty() ? reinterpret_cast<const T *>(&t) : &v.front();
|
||||
}
|
||||
template<typename T, typename Alloc> T *data(std::vector<T, Alloc> &v) {
|
||||
template<typename T, typename Alloc = std::allocator<T>>
|
||||
T *data(std::vector<T, Alloc> &v) {
|
||||
// Eventually the returned pointer gets passed down to memcpy, so
|
||||
// we need it to be non-null to avoid undefined behavior.
|
||||
static uint8_t t;
|
||||
@@ -653,7 +654,7 @@ class FlatBufferBuilder {
|
||||
/// buffer as a `vector`.
|
||||
/// @return Returns a typed `Offset` into the serialized data indicating
|
||||
/// where the vector is stored.
|
||||
template<typename T, typename Alloc>
|
||||
template<typename T, typename Alloc = std::allocator<T>>
|
||||
Offset<Vector<T>> CreateVector(const std::vector<T, Alloc> &v) {
|
||||
return CreateVector(data(v), v.size());
|
||||
}
|
||||
@@ -710,7 +711,7 @@ class FlatBufferBuilder {
|
||||
/// buffer as a `vector`.
|
||||
/// @return Returns a typed `Offset` into the serialized data indicating
|
||||
/// where the vector is stored.
|
||||
template<typename Alloc>
|
||||
template<typename Alloc = std::allocator<std::string>>
|
||||
Offset<Vector<Offset<String>>> CreateVectorOfStrings(
|
||||
const std::vector<std::string, Alloc> &v) {
|
||||
return CreateVectorOfStrings(v.cbegin(), v.cend());
|
||||
@@ -839,7 +840,7 @@ class FlatBufferBuilder {
|
||||
/// serialize into the buffer as a `vector`.
|
||||
/// @return Returns a typed `Offset` into the serialized data indicating
|
||||
/// where the vector is stored.
|
||||
template<typename T, typename Alloc>
|
||||
template<typename T, typename Alloc = std::allocator<T>>
|
||||
Offset<Vector<const T *>> CreateVectorOfStructs(
|
||||
const std::vector<T, Alloc> &v) {
|
||||
return CreateVectorOfStructs(data(v), v.size());
|
||||
@@ -855,7 +856,7 @@ class FlatBufferBuilder {
|
||||
/// to the FlatBuffer struct.
|
||||
/// @return Returns a typed `Offset` into the serialized data indicating
|
||||
/// where the vector is stored.
|
||||
template<typename T, typename S, typename Alloc>
|
||||
template<typename T, typename S, typename Alloc = std::allocator<T>>
|
||||
Offset<Vector<const T *>> CreateVectorOfNativeStructs(
|
||||
const std::vector<S, Alloc> &v, T (*const pack_func)(const S &)) {
|
||||
return CreateVectorOfNativeStructs<T, S>(data(v), v.size(), pack_func);
|
||||
@@ -869,7 +870,7 @@ class FlatBufferBuilder {
|
||||
/// serialize into the buffer as a `vector`.
|
||||
/// @return Returns a typed `Offset` into the serialized data indicating
|
||||
/// where the vector is stored.
|
||||
template<typename T, typename S, typename Alloc>
|
||||
template<typename T, typename S, typename Alloc = std::allocator<S>>
|
||||
Offset<Vector<const T *>> CreateVectorOfNativeStructs(
|
||||
const std::vector<S, Alloc> &v) {
|
||||
return CreateVectorOfNativeStructs<T, S>(data(v), v.size());
|
||||
@@ -890,7 +891,7 @@ class FlatBufferBuilder {
|
||||
/// serialize into the buffer as a `vector`.
|
||||
/// @return Returns a typed `Offset` into the serialized data indicating
|
||||
/// where the vector is stored.
|
||||
template<typename T, typename Alloc>
|
||||
template<typename T, typename Alloc = std::allocator<T>>
|
||||
Offset<Vector<const T *>> CreateVectorOfSortedStructs(
|
||||
std::vector<T, Alloc> *v) {
|
||||
return CreateVectorOfSortedStructs(data(*v), v->size());
|
||||
@@ -904,7 +905,7 @@ class FlatBufferBuilder {
|
||||
/// serialize into the buffer as a `vector`.
|
||||
/// @return Returns a typed `Offset` into the serialized data indicating
|
||||
/// where the vector is stored.
|
||||
template<typename T, typename S, typename Alloc>
|
||||
template<typename T, typename S, typename Alloc = std::allocator<T>>
|
||||
Offset<Vector<const T *>> CreateVectorOfSortedNativeStructs(
|
||||
std::vector<S, Alloc> *v) {
|
||||
return CreateVectorOfSortedNativeStructs<T, S>(data(*v), v->size());
|
||||
@@ -982,7 +983,7 @@ class FlatBufferBuilder {
|
||||
/// offsets to store in the buffer in sorted order.
|
||||
/// @return Returns a typed `Offset` into the serialized data indicating
|
||||
/// where the vector is stored.
|
||||
template<typename T, typename Alloc>
|
||||
template<typename T, typename Alloc = std::allocator<T>>
|
||||
Offset<Vector<Offset<T>>> CreateVectorOfSortedTables(
|
||||
std::vector<Offset<T>, Alloc> *v) {
|
||||
return CreateVectorOfSortedTables(data(*v), v->size());
|
||||
|
||||
Reference in New Issue
Block a user