How is std::vector
implemented, using what data structure? When I write
void f(int n) {
std::vector v(n);
...
}
Is
Your v
is allocated in automatic memory. (commonly known as the stack, yes)
The implementation details are not specified, but most commonly it's implemented using a dynamic array which is resized if you attempt to add more elements than the previous allocation can hold.
The standard only specifies the interface (which methods it should have) and execution time boundaries.
Since vector
is a template, the implementation is visible, so locate your
file and start inspecting.