I’m creating a textbox for my game. Most of the string related functions in the engine I’m using use std::string* or std::string& .
Here is some of the constraints:
The rest of my Gui API returns std::string& for the getText() function, so I need to be able to return a std::string& for the text.
I implemented the textbox using std::string, and making lines of strings. The problem is that it gets slow with too much text so I instead want to use a string that is a List. Rendering I assume will be slower due to caching though. How could I implement a string class with fast insertion / removal while being able to provide a std::string and a seemingly contiguous stream of chars?
Thanks
Unfortunately, you really can’t; the
std::stringclass is required to have contiguous storage so that thedatamember function can work correctly. If you want to use a faster representation of a string for an editor buffer, such as a rope, you’re going to have to have the function return something of a different type.