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).

0

u/foonathan 5d ago

Me too. See also: cstring_view duplicating everything from string_view.

2

u/_Noreturn 5d ago

The solution is some sort of member callable syntax for free functions which was going to happen with operstor |>. The only reason they are members is because of syntax