Inside STL: The vector -- Raymond Chen
The C++ language comes with a standard library, and although implementations are welcome to implement the library types in whatever manner they choose, they are constraints imposed by the standard which often force one of a small number of possible implementations.
Inside STL: The vector
By Raymond Chen
The std::vector is one of those types which is constrained to the point that there’s really only one viable implementation.
Internally, a std::vector basically looks like this:
template<typename T>
struct vector
{
T* first;
T* last;
T* end;
};
The first is a pointer to the beginning of a single memory allocation that holds the vector contents.
The last is a pointer one past the end of the last valid vector element.
The end is a pointer one past the end of the last allocated memory for the vector.
The picture for this is as follows:


In this article, we’d shed some light on the implementation of
In this article, we are going to review two new features of C++23. Now the language allows the call operator (
The Curiously Recurring Template Pattern (CRTP) is a heavily used idiom in C++. It is similarly resistant to understanding as the classic design pattern visitor I presented in my last post: “
Some time ago I started working on P1705 Enumerating Core Undefined Behavior, I have collected a large set of undefined behavior (UB) during that time. There is going to be a lot of work involved in getting the annex into shape and editing it into the standard. While this work is ongoing, I will take some time to write blog posts to explore the set of undefined behaviors.