How to manage string slices with less overhead?

I deal with giant (up to 2 GB) strings and their slices in a C ++ program. C-style lines seem unreliable under such circumstances, but can be cut trivially (without "\ 0" at the end). On the other hand, as I understand it, std :: string :: substr copies the slice, so I have to perform at least one additional add operation (index + base) for indexing, so that rational use of memory.

+4
source share
1 answer

The most common solution would be to create a slice object, the interface you need, and use it. A slice object can consist of two iterators, a start and an end.

+8
source

Source: https://habr.com/ru/post/1411482/


All Articles