首页 > 解决方案 > Is there any performance penalty for using std::stack rather than the underlying std::deque?

问题描述

I want to implement a LIFO stack object. The C++ standard lib provides a convenient stack structure (std::stack) with a very simple interface. By default, it uses std::deque as its underlying container.

Is there any performance penalty to using std::stack rather than using std::deque directly?

My use case would involve many pops and pushes per second.

标签: c++stack

解决方案


No, there will be no performance profile changes by using std::stack (as compared to using std::deque directly).


推荐阅读