google / flatbuffers

FlatBuffers: Memory Efficient Serialization Library
https://flatbuffers.dev/
Apache License 2.0
22.52k stars 3.19k forks source link

Generated CreateXDirect with std::span<T> or "T* + size" payloads #8279

Open pierricgimmig opened 2 months ago

pierricgimmig commented 2 months ago

In generated C++ code, the CreateXDirect functions take in a payload of type const std::vector<uint8_t> *payload.

The caller doesn't always have a std::vector at hand, and creating one might not always be possible. In such cases, is there a way to call into a CreateXDirect function or equivalent without allocating?

If not, maybe adding a version of CreateXDirect functions that takes in a std::span or "T* + size" would be a good idea?

Thanks