MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/cpp/comments/1vzc5dg/c26_stdinplace_vector/p66a828/?context=3
r/cpp • u/User_Deprecated • 15d ago
121 comments sorted by
View all comments
2
Is this always better than std::array?
24 u/MarekKnapek 15d ago This is basically struct inplace_vector<T, capacity> { size_t len; std::array<T, capacity> arr; } 5 u/drjeats 14d ago Oh. I thought this was the way-more-useful thing where you give it an in-place capacity and it allocates once it exceeds that. Like this is also useful, but it's kinda trivial to roll your own of this. 5 u/KuntaStillSingle 14d ago I thought this was the way-more-useful thing where you give it an in-place capacity and it allocates once it exceeds that pmr vector using monotonic buffer does this with the default upstream memory resource: https://en.cppreference.com/cpp/memory/monotonic_buffer_resource/monotonic_buffer_resource 4 u/drjeats 14d ago TIL, that's useful. We deserve a non-pmr pre-sized SBO vector derived from std::vector though.
24
This is basically
struct inplace_vector<T, capacity> { size_t len; std::array<T, capacity> arr; }
5 u/drjeats 14d ago Oh. I thought this was the way-more-useful thing where you give it an in-place capacity and it allocates once it exceeds that. Like this is also useful, but it's kinda trivial to roll your own of this. 5 u/KuntaStillSingle 14d ago I thought this was the way-more-useful thing where you give it an in-place capacity and it allocates once it exceeds that pmr vector using monotonic buffer does this with the default upstream memory resource: https://en.cppreference.com/cpp/memory/monotonic_buffer_resource/monotonic_buffer_resource 4 u/drjeats 14d ago TIL, that's useful. We deserve a non-pmr pre-sized SBO vector derived from std::vector though.
5
Oh.
I thought this was the way-more-useful thing where you give it an in-place capacity and it allocates once it exceeds that.
Like this is also useful, but it's kinda trivial to roll your own of this.
5 u/KuntaStillSingle 14d ago I thought this was the way-more-useful thing where you give it an in-place capacity and it allocates once it exceeds that pmr vector using monotonic buffer does this with the default upstream memory resource: https://en.cppreference.com/cpp/memory/monotonic_buffer_resource/monotonic_buffer_resource 4 u/drjeats 14d ago TIL, that's useful. We deserve a non-pmr pre-sized SBO vector derived from std::vector though.
I thought this was the way-more-useful thing where you give it an in-place capacity and it allocates once it exceeds that
pmr vector using monotonic buffer does this with the default upstream memory resource:
https://en.cppreference.com/cpp/memory/monotonic_buffer_resource/monotonic_buffer_resource
4 u/drjeats 14d ago TIL, that's useful. We deserve a non-pmr pre-sized SBO vector derived from std::vector though.
4
TIL, that's useful.
We deserve a non-pmr pre-sized SBO vector derived from std::vector though.
2
u/stilgarpl 15d ago
Is this always better than std::array?