r/cpp 6d ago

C++26: std::inplace_vector

https://www.sandordargo.com/blog/2026/08/26/cpp26-inplace-vector
173 Upvotes

121 comments sorted by

View all comments

6

u/matthieum 5d ago

Honestly, I'm a bit saddened by this addition.

Don't get me wrong, the functionality is really useful. But:

  1. Now, most (all?) methods of vector need to be "duplicated" in inplace_vector.
  2. None of the other collections benefit. Not even std::string.

A more general solution to the problem would have been an inplace_allocator -- which requires a different API than allocator -- which could be applied to every container (standard or not).

3

u/SyntheticDuckFlavour 4d ago

The concept is useful, especially in a gpu environment where you can’t allocate memory dynamically. Also, inplace_allocator just adds another layer of complexity when all I want is something like a static vector