small string optimization for vector?

后端 未结 4 1954
野的像风
野的像风 2020-12-06 04:33

I know several (all?) STL implementations implement a \"small string\" optimization where instead of storing the usual 3 pointers for begin, end and capacity a string will s

4条回答
  •  一向
    一向 (楼主)
    2020-12-06 04:35

    Boost 1.58 was just released and it's Container library has a small_vector class based on the LLVM SmallVector.

    There is also a static_vector which cannot grow beyond the initially given size. Both containers are header-only.

    facebook's folly library also has some awesome containers.

    It has a small_vector which can be configured with a template parameter to act like boost's static or small vectors. It can also be configured to use small integer types for it's internal size bookkeeping which given that they are facebook is no surprise :)

    There is work in progress to make the library cross platform so Windows/MSVC support should land some day...

提交回复
热议问题