I've searched this up but was unable to find answers. We all know that a lot of the STL containers are re-sizable (except for things like std::array
, etc.), but they all are allocated on the heap. So I was wondering if a re-sizable container could be built on the stack and if somebody could give me an example.
A thought about this:
I think that a linked list would could be built on the stack because (as far as I know) you only allocate the nodes on the heap because of the lifetime, but all in all, I'm not sure if that would work.