r/cpp 6d ago

C++26: std::inplace_vector

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

121 comments sorted by

View all comments

Show parent comments

0

u/MarekKnapek 5d ago

Hey guys, yes, I get it. I simplified it. To get the general "gist" or "shape" or "feeling" about this data structure. I guess, I oversimplified it.

struct inplace_vector<T, capacity>
{
    size_t len;
    std::array<std::aligned_storage<T>, capacity> arr;
}

Does this look better?

-1

u/n1ghtyunso 4d ago

no because std::aligned_storage<T> is the wrong type, which is also why it is being deprecated in C++23.

I don't think you oversimplified it, people are just being pedantic.
And because of this, I just wanted to give you a heads-up.

The best way to describe it is likely to steal an idea directly from the standard:
use an exposition-only type in italic that hand-waves the storage detail away :P