Do anyone know if there is a STL interface compatible string class that allocates memory for small strings on the stack (up to a certain threshold) and the heap for larger strings ?
I’m looking to optimize a program and I’m using allot of small local strings that easily could fit on the stack, instead of being allocated on the heap.
You can provide a custom allocator for
std::basic_string(it is the third template argument). This answer explains how use that and links to an implementation of a stack-allocator that can be used.