Does std::stack expose iterators?

后端 未结 5 1234
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-29 08:57

Does the std::stack in the C++ STL expose any iterators of the underlying container or should I use that container directly?

5条回答
  •  醉梦人生
    2020-11-29 09:32

    If you need a stack with iterators, you have two choices:

    • std::vector using push_back(), pop_back().

    • std::deque with either push_back()/pop_back() or push_front()/pop_front().

提交回复
热议问题