MutantStack.hpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* MutantStack.hpp :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2026/01/14 17:17:11 by bchanot #+# #+# */
  9. /* Updated: 2026/01/14 19:17:32 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #ifndef MUTANTSTACK_HPP
  13. # define MUTANTSTACK_HPP
  14. # include <iostream>
  15. # include <string>
  16. #include <deque>
  17. #include <stack>
  18. #include <iterator>
  19. template < typename T, typename Container = std::deque<T> >
  20. class MutantStack : public std::stack<T, Container>
  21. {
  22. public:
  23. MutantStack() : MutantStack<T, Container>::stack() {};
  24. MutantStack( MutantStack const & src ) : MutantStack<T, Container>::stack(src) {};
  25. virtual ~MutantStack() {};
  26. MutantStack<T, Container> &operator=( MutantStack const & rhs ) {
  27. if (this != &rhs)
  28. this->MutantStack<T, Container>::stack::operator=(rhs);
  29. return *this;
  30. }
  31. typedef typename Container::iterator iterator;
  32. typedef typename Container::reverse_iterator reverse_iterator;
  33. typedef typename Container::const_iterator const_iterator;
  34. typedef typename Container::const_reverse_iterator const_reverse_iterator;
  35. iterator begin() { return this->c.begin(); };
  36. const_iterator begin() const { return this->c.begin(); };
  37. iterator end() { return this->c.end(); };
  38. const_iterator end() const { return this->c.end(); };
  39. reverse_iterator rbegin() { return this->c.rbegin(); };
  40. const_reverse_iterator rbegin() const { return this->c.rbegin(); };
  41. reverse_iterator rend() { return this->c.rend(); };
  42. const_reverse_iterator rend() const { return this->c.rend(); };
  43. };
  44. #endif /* ***************************************************** MUTANTSTACK_H */