String class allocating on stack for small strings?

后端 未结 4 1856
臣服心动
臣服心动 2021-01-17 20:25

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 s

4条回答
  •  佛祖请我去吃肉
    2021-01-17 20:41

    The vstring (__versa_string) implementation from gcc can do the small string optimization and has a std string interface. If you happen to be using gcc it's easy enough to include ext/vstring. Otherwise you may be able to adapt it to your compiler/enviroent.

提交回复
热议问题