If I was gonna write a class along these lines, here's what I'd go for:
- In the constructor, take a pointer to a mutable null-terminated stringĀ
- In the 'substr' method, save the value of the one-past-the-last character and replace it with a null
- When the string is reset, place the one-past-the-last character back where it was
Of course this wouldn't be thread-safe, but it would be a nice efficient way to manipulate and re-use null-terminated strings.