Описание тега stdvector

NoneStd ::vector is a contiguous sequence container in the C++ standard library. Its storage is handled automatically, so appending elements or resizing may cause the vector to allocate more memory. Use this tag for questions about std::vector or involving a std::vector.

A std::vector is a sequential container that (most notably) supports:

  • random access to elements using operator[]
  • constant time insertion and removal of elements at the end using push_back() and pop_back()
  • linear time removal of elements at the beginning or in the middle using erase()

The storage of the vector is handled automatically, being expanded and contracted as needed. Vectors usually occupy more space than static arrays, because more memory is allocated to handle future growth. This way a vector does not need to reallocate each time an element is inserted, but only when the additional memory is exhausted.

See also the Standard Library stdlib.