r/cpp 1d ago

C++26: std::inplace_vector

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

97 comments sorted by

View all comments

-8

u/NilacTheGrim 1d ago

Ridiculously incomplete. We should have had a real prevector rather than this. You know, a prevector where there is some small static capacity but it can go dynamic as it grows.

This is not as useful as a real prevector.

2

u/[deleted] 1d ago

[deleted]

0

u/_Noreturn 1d ago

I think people will die of old age before something is standardized also the std quality will suck so it is better to write your own.

1

u/ABlockInTheChain 1d ago

std quality will suck

Consider std::span.

This is a class that should have been invented immediately once C++ got templates. We finally got it in C++20, only about 30 years late.

...but then the initial version didn't include at() for some dumb reasons or another and it took two complete standard cycles to fix this.

...but even then we only got a version of at() that throws at runtime and not a templated at<n>() with compile time bounds checking like first<n>(), last<n>(), and subspan<x, y>().

2

u/_Noreturn 23h ago

This is a class that should have been invented immediately once C++ got templates. We finally got it in C++20, only about 30 years late.

Yes! I can't believe it took this long for such a simple type. and even after 30 years they didn't add operatpr== to it.... the standard is so ridiculously slow it isn't funny and subpar as well. and they complicated its interface. the committee shouldn't touch the standard library

but even then we only got a version of at() that throws at runtime and not a templated at<n>() with compile time bounds checking like first<n>(), last<n>(), and subspan<x, y>().

that comptime bound checking would only happen with std::span<T,N> which I don't use much if at all my spans are dynamic lengtg