forked from BigfootDev/flatbuffers
vector-type
This commit is contained in:
@@ -337,6 +337,27 @@ constructor in the following format: `custom_str_class(const char *, size_t)`.
|
||||
Please note that the character array is not guaranteed to be NULL terminated,
|
||||
you should always use the provided size to determine end of string.
|
||||
|
||||
## Using different vector type
|
||||
|
||||
By default the object tree's vector fields are built out of `std::vector`,
|
||||
but you can influence this either globally (using the `--cpp-vector-type`
|
||||
argument to `flatc`) or per field using the `cpp_vector_type` attribute, to
|
||||
use any other vector-like template type (e.g. `eastl::vector`).
|
||||
|
||||
The type must be a template taking a single element type argument
|
||||
(`my_vector<T>`), and must support the following member functions:
|
||||
`resize()`, `reserve()`, `size()`, `data()`, `operator[]`, `emplace_back()`,
|
||||
and `begin()`/`end()`. This matches the subset of `std::vector`'s interface
|
||||
that generated code relies on.
|
||||
|
||||
Note that unlike `std::vector<bool>`, the custom vector type must not use a
|
||||
bit-packed specialization for `bool` elements, since generated code accesses
|
||||
`data()` as a contiguous `bool` array.
|
||||
|
||||
As with custom string types, the header defining the custom vector type is
|
||||
not automatically included; use `--cpp-include` to add the necessary
|
||||
`#include`.
|
||||
|
||||
## Reflection (& Resizing)
|
||||
|
||||
There is experimental support for reflection in FlatBuffers, allowing you to
|
||||
|
||||
Reference in New Issue
Block a user