What is the most efficient way to prepend std::string
? Is it worth writing out an entire function to do so, or would it take only 1 - 2 lines? I\'m not seeing anyth
myString.insert(0, otherString);
Let the Standard Template Library writers worry about efficiency; make use of all their hours of work rather than re-programming the wheel.
This way does both of those.
As long as the STL implementation you are using was thought through you'll have efficient code. If you're using a badly written STL, you have bigger problems anyway :)