fork(5) download
  1. #include <queue>
  2. #include <deque>
  3. #include <iostream>
  4.  
  5. template<typename T, typename Container=std::deque<T> >
  6. class iterable_queue : public std::queue<T,Container>
  7. {
  8. public:
  9. typedef typename Container::iterator iterator;
  10. typedef typename Container::const_iterator const_iterator;
  11.  
  12. iterator begin() { return this->c.begin(); }
  13. iterator end() { return this->c.end(); }
  14. const_iterator begin() const { return this->c.begin(); }
  15. const_iterator end() const { return this->c.end(); }
  16. };
  17.  
  18. int main() {
  19. iterable_queue<int> int_queue;
  20. for(int i=0; i<10; ++i)
  21. int_queue.push(i);
  22. for(auto it=int_queue.begin(); it!=int_queue.end();++it)
  23. std::cout << *it << "\n";
  24. return 0;
  25. }
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
0
1
2
3
4
5
6
7
8
9