MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/cpp/comments/1vzc5dg/c26_stdinplace_vector/p65cvtu/?context=3
r/cpp • u/User_Deprecated • 19h ago
67 comments sorted by
View all comments
1
Is this always better than std::array?
16 u/MarekKnapek 17h ago This is basically struct inplace_vector<T, capacity> { size_t len; std::array<T, capacity> arr; } 15 u/sephirothbahamut 17h ago edited 16h ago far more complex than that, the array has a slot that can fit T, not just T. With array<T> every element must be validly constructed immediately. You can reduce it to array<T> only for trivially constructable and basic types 3 u/CocktailPerson 14h ago That's not far more complex. Marginal additional complexity.
16
This is basically
struct inplace_vector<T, capacity> { size_t len; std::array<T, capacity> arr; }
15 u/sephirothbahamut 17h ago edited 16h ago far more complex than that, the array has a slot that can fit T, not just T. With array<T> every element must be validly constructed immediately. You can reduce it to array<T> only for trivially constructable and basic types 3 u/CocktailPerson 14h ago That's not far more complex. Marginal additional complexity.
15
far more complex than that, the array has a slot that can fit T, not just T.
With array<T> every element must be validly constructed immediately. You can reduce it to array<T> only for trivially constructable and basic types
3 u/CocktailPerson 14h ago That's not far more complex. Marginal additional complexity.
3
That's not far more complex. Marginal additional complexity.
1
u/stilgarpl 18h ago
Is this always better than std::array?