Skip to content

Commit

Permalink
fix(c++): add support to std::vector<bool, CustomAlloc> for CreateVector
Browse files Browse the repository at this point in the history
  • Loading branch information
sssooonnnggg committed Aug 14, 2024
1 parent fb9afba commit 2a89df9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/flatbuffers/flatbuffer_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,8 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl {
// vector<bool> may be implemented using a bit-set, so we can't access it as
// an array. Instead, read elements manually.
// Background: https://isocpp.org/blog/2012/11/on-vectorbool
Offset<Vector<uint8_t>> CreateVector(const std::vector<bool> &v) {
template<typename Alloc = std::allocator<bool>>
Offset<Vector<uint8_t>> CreateVector(const std::vector<bool, Alloc> &v) {
StartVector<uint8_t>(v.size());
for (auto i = v.size(); i > 0;) {
PushElement(static_cast<uint8_t>(v[--i]));
Expand Down

0 comments on commit 2a89df9

Please sign in to comment.