I came across this:
Standard C++ Containers
It triggered me the question, how are stacks implemented in STL?
I am looking for a description similar to:
How is C++ std::vector implemented?
What really is a deque in STL?
stack is an adapter which uses another container for the underlying storage, and links the functions push, pop, emplace etc. to the relevant functions in the underlying container.
By default, std::stack uses std::deque as underlying container. But you can specify your own, e.g. std::stack<T, std::vector<T>> s;.
For more details about this, see cppreference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With