Numerous answers and comments on SO claim that using std::stack is pretty much useless, but don't really give a reason other than "Use a std::vector or std::deque instead."
Why? What's wrong with it?
Evidence of Claims:
There is a saying that goes like this:
Don't tempt someone to do something you don't want him/her to do.
A stack is a well-defined data structure. It's behaviour is well implemented by std::stack.
If all you need is a stack and nothing more, then go for std::stack. It will help you stick to the purpose of the data structure, plus make your program clearer to understand and easier to maintain.
But try to evaluate whether you will ever need more functionality than a stack provides.
For example, a good reason to argue in favour of std::deque or std::vector is iterators, as already stated.
In all cases provided as evidence for the fact that using std::stack is pretty much useless, it was such additional functionality (beyond that of a stack) which motivated abandoning std::stack in favour of another container.
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