This commit is contained in:
aortigos
2026-04-21 12:00:29 +02:00
parent 9a3884a783
commit ca8a9c7010
4 changed files with 189 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* MutantStack.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/04/21 11:32:08 by aortigos #+# #+# */
/* Updated: 2026/04/21 11:32:08 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef MUTANTSTACK_HPP
# define MUTANTSTACK_HPP
# include <iostream>
# include <stack>
template <typename T>
class MutantStack : public std::stack<T>
{
private:
public:
MutantStack();
MutantStack(const MutantStack &other);
MutantStack& operator=(const MutantStack &other);
~MutantStack();
typedef typename std::stack<T>::container_type::iterator iterator;
typedef typename std::stack<T>::container_type::const_iterator const_iterator;
iterator begin();
iterator end();
const_iterator begin() const;
const_iterator end() const;
};
#include "MutantStack.tpp"
#endif

View File

@@ -0,0 +1,63 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* MutantStack.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/04/21 11:32:08 by aortigos #+# #+# */
/* Updated: 2026/04/21 11:32:08 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
template<typename T>
MutantStack<T>::MutantStack() : std::stack<T>()
{
// std::cout << "Span default constructor called" << std::endl;
}
template<typename T>
MutantStack<T>::MutantStack(const MutantStack &other)
{
*this = other;
}
template<typename T>
MutantStack<T>& MutantStack<T>::operator=(const MutantStack &other)
{
if (this != &other)
{
std::stack<T>::operator=(other);
}
return (*this);
}
template<typename T>
MutantStack<T>::~MutantStack()
{
// std::cout << "MutantStack destructor called" << std::endl;
}
template<typename T>
typename MutantStack<T>::iterator MutantStack<T>::begin()
{
return (this->c.begin());
}
template<typename T>
typename MutantStack<T>::iterator MutantStack<T>::end()
{
return (this->c.end());
}
template<typename T>
typename MutantStack<T>::const_iterator MutantStack<T>::begin() const
{
return (this->c.begin());
}
template<typename T>
typename MutantStack<T>::const_iterator MutantStack<T>::end() const
{
return (this->c.end());
}