Why is sizeof(string) == 32?

前端 未结 6 1926
再見小時候
再見小時候 2020-11-29 05:20

What is the overhead in the string structure that causes sizeof() to be 32 ?

6条回答
  •  时光取名叫无心
    2020-11-29 05:58

    std::string typically contains a buffer for the "small string optimization" --- if the string is less than the buffer size then no heap allocation is required.

提交回复
热议问题