The C++26 inplace_vector container
cppdashboard.dev/r/2026/10/the-cpp26-inplace-vector-containerThis article discusses the new std::inplace_vector container introduced in C++26, which combines features of std::array and std::vector. It explains how it works and when to use it.
From the article
The C++26 standard features a new container called std::inplace_vector , that sits in between the std::array and std::vector containers. It’s a container with a compiled-time fix capacity – like std::array , but a runtime variable size – like std::vector . In this article, we will discuss how it works and when to use it.
Before we discuss std::inplace_vector , let’s briefly look at the other two mentioned containers:
There are cases were you need the semantics of std::array for a fixed (maximum) number of elements, but mixed with those of std::vector for being able to increase and decrease the capacity. If you use a std::array , you need to use an additional counter that you increment and decrement as elements are added or removed. But decrementing the counter does not destruct the…
Share this resource