I'm dealing with giant (up to 2GB) strings and their slices in C++ program. C-style strings seem to be unreliable under such circumstances, but can be sliced trivially (without '\0' at the end). On the other hand, as I understood, std::string::substr copies the slice, therefore I should perform at least one extra addition operation (index + base) per indexing in order to keep memory usage rational.
The most general solution would be to create a slice object, with the interface you need, and use that. The slice object could consist of two iterators, the start and the end.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With