3 ms·
What would be the point of adding a string as int32 offset/size pair to the standard library? It would be meaningless without supporting infrastructure to link
by sagarm 4y ago
What would be the point of adding a string as int32 offset/size pair to the standard library? It would be meaningless without supporting infrastructure to link it to a backing buffer, and it can't represent strings over 4GB. If it's something that you can make work, declaring the typedef or struct is trivial.
string_view is a useful general purpose tool that implements the std::string API for e.g. taking strings of various types in general purpose function signatures. Obviously it's not meant to be serialized and deserialized. It works well for its intended purpose.
The two are not mutually exclusive: you could turn your 32-bit offset/length pair into a string_view to pass to functions that operate in the context of a single string.
- jstimpfle 4y agoWhere did I mention standard library? > It works well for its intended purpose. The intended purpose is quite general. Which admits other, better solutions in specific applications.