[boost][container][static_vector] Stack or heap?
Does the boost::container::static_vector allocate its memory on the stack or heap. From what I could make of the code, it seems to allocate on the stack. What happens if the requested size exceeds the stack size limits? Aaron
2014-09-08 19:06 GMT+02:00 Aaron Levy
Does the boost::container::static_vector allocate its memory on the stack or heap.
Same as plain old int - where does int allocate its memory? It does not allocate. It just resides wherever you define it to be. The memory for elements of static_vector is inside the static_vector object itself. When you put your object on the stack, the memory is on the stack.
From what I could make of the code, it seems to allocate on the stack. What happens if the requested size exceeds the stack size limits?
Aaron
When an object doesn't fit on the stack (no matter if it's a static_vector instance or a plain old int), you typically get a stack overflow error and your program crashes. HTH, Kris
participants (2)
-
Aaron Levy
-
Krzysztof Czainski