What happens to the underlying storage upon vector's copy/move assignment?

后端 未结 3 1309
遥遥无期
遥遥无期 2020-12-10 05:42

For std::vector\'s copy assignment, is reallocation of storage and shrink of capacity allowed when the source\'s size is smaller than the destination\'s capacity? Or is it

3条回答
  •  轮回少年
    2020-12-10 06:07

    To answer your PS: At least for std::string, you cannot assume that the handling of strings are similar to the handling of a vector of chararacters.

    COW (Copy-on-Write) is not mandatory to implement string, and not all library-implementations do this.

提交回复
热议问题