How is C++ std::vector implemented?

后端 未结 9 1328
不思量自难忘°
不思量自难忘° 2020-11-28 06:49

I have been using std::vector a lot, and recently I asked myself this question: \"How is std::vector implemented?\"

I had two alternatives:

9条回答
  •  情深已故
    2020-11-28 07:29

    It's implemented by using an underlying array.

    It's not possible to implement a std::vector with a linked list because the standard guarantees the elements in the list will be held in contiguous memory.

提交回复
热议问题