fork download
  1. #include <iostream>
  2. #include <stack>
  3.  
  4.  
  5. template<typename Type, typename Container = std::deque<Type>>
  6. class stack : protected std::stack<Type, Container> {
  7.  
  8. using base_type = std::stack<Type, Container>;
  9.  
  10. public:
  11. using container_type = typename base_type::container_type;
  12. using value_type = typename base_type::value_type;
  13. using size_type = typename base_type::size_type;
  14. using reference = typename base_type::reference;
  15. using const_reference = typename base_type::const_reference;
  16.  
  17.  
  18. using base_type::top;
  19.  
  20. using base_type::empty;
  21. using base_type::size;
  22.  
  23. using base_type::push;
  24. using base_type::emplace;
  25. using base_type::pop;
  26. using base_type::swap;
  27.  
  28. using base_type::base_type;
  29.  
  30. container_type & get_container() noexcept {
  31. return this->c;
  32. }
  33. constexpr container_type const& get_container() const noexcept {
  34. return this->c;
  35. }
  36. };
  37.  
  38.  
  39. int main() {
  40. stack<int> values;
  41.  
  42. for (int i = 0; i != 10; ++i) {
  43. values.push(i);
  44. }
  45.  
  46. for (auto value : values.get_container()) {
  47. std::cout << value << std::endl;
  48. }
  49. }
  50.  
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
0
1
2
3
4
5
6
7
8
9