C++ Internals :: STL vector, Part I

August 5, 2015 in C++, Programming, Uncategorized by Adrian Marius

c++Today is a great day to disembowel something. How’s about a well-known std::vector? You think there is nothing more you can learn about it? Believe me, you’re wrong.

In this series of three articles we are going to check:

what is std::vector and how it works (suppress a yawn)
vector’s growth factor
VC++ Debug’s “aux object”
new C++11’s methods
miscellaneous things


std::vector is the most famous sequence container in C++ world that encapsulates dynamic size arrays. Other sequence containers you might be aware of arestd::forward_list (since C++11), std::list, std::deque and std::array(since C++11). But the scope of this article is std::vector. So, let’s get started.

The items in std::vector are stored contiguously in memory: