I need a string field in a Protobuf message to use a custom allocator for its internal char* buffer, instead of the default global allocator.
I am aware that google::protobuf::Arena will allocate the std::string object itself in the arena, but this does not affect the allocator used for that string's internal data buffer.
Ideally, I'd like the field to be a std::basic_string<..., MyCustomAllocator>. The [ctype] option seems limited to CORD and STRING_PIECE and doesn't appear to support arbitrary types.
Is there any way to control the allocator for a string field?
I am also considering using std::string_view. The idea is to define string_view field in my .proto and then manage the memory for the string buffer myself, outside of Protobuf. Do you see any pitfalls with this approach?