Suppose i have physics engine which need to solve systems of linear equation size of which is unknown in forward, but after i know it, i will not change it. One such matrix may easily take hundreds of kilobytes. The problem with vector is that i never really know how much space it has allocated and i don't want to allocate more than needed.
Most discussion tell us to use std::vector
, but should i use std::unique_ptr<T[]>
instead? Hm... maybe i need to use std allocator as this answer suggests?
From the standard:
After reserve(), capacity() is greater or equal to the argument of reserve if reallocation happens; and equal to the previous value of capacity() otherwise.
So it is not the option for me to use reserve.
I also found that there was proposition for dynarray
which should have handled my case, and for now that is the way i'm going to take, if no other propositions will come.