2 ms·
That's what absl::InlinedVector does. It has internal space for N and if needed it reallocates. Brilliant if you can arrive at a reasonable N. https://github.c
by jeffbee 5y ago
That's what absl::InlinedVector does. It has internal space for N and if needed it reallocates. Brilliant if you can arrive at a reasonable N.
https://github.com/abseil/abseil-cpp/blob/master/absl/container/inlined_vector.h https://github.com/abseil/abseil-cpp/blob/master/absl/contai...
- beached_whale 5y agoPMR is slightly different, the memory wouldn't exist in the vector itself but up the stack. InlinedVector looks like SBO used in string, pretty neat still. N is actually pretty simple here and doesn't need to be perfect. I have used 1-4kb / sizeof( T ) and it seems to work well. 4kb is an interesting number in that it is often the OS page size and it is what libc++ dequeue uses. But the memory that isn't used can be returned to the system and it costs about the same as sizeof( T )