「✨」 feat: finished ex02
This commit is contained in:
59
ex02/MutantStack.hpp
Normal file
59
ex02/MutantStack.hpp
Normal file
@ -0,0 +1,59 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* MutantStack.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/16 10:44:35 by adjoly #+# #+# */
|
||||
/* Updated: 2025/04/19 20:51:25 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stack>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
static void _log(std::string emoji, std::string what, std::string who,
|
||||
std::string str) {
|
||||
#ifdef VERBOSE
|
||||
if (who.empty())
|
||||
std::cout << "「" << emoji << "」" << what << ": " << str << std::endl;
|
||||
else
|
||||
std::cout << "「" << emoji << "」" << what << "(" << who << "): " << str
|
||||
<< std::endl;
|
||||
#else
|
||||
(void)emoji, (void)what, (void)who, (void)str;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T> class MutantStack : public std::stack<T> {
|
||||
public:
|
||||
MutantStack(void) {
|
||||
_log("➕", "MutantStack", "", "default constructor called");
|
||||
}
|
||||
MutantStack(const MutantStack &cpy) : std::stack<T>(cpy) {
|
||||
_log("➕", "MutantStack", "", "copy constructor called");
|
||||
}
|
||||
~MutantStack(void) { _log("➖", "MutantStack", "", "destructor called"); }
|
||||
|
||||
MutantStack &operator=(const MutantStack &cpy) {
|
||||
if (this != &cpy) {
|
||||
std::stack<T>::operator=(cpy);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
typedef typename std::stack<T>::container_type::iterator iterator;
|
||||
iterator begin(void) { return std::stack<T>::c.begin(); }
|
||||
iterator end(void) { return std::stack<T>::c.end(); }
|
||||
|
||||
typedef
|
||||
typename std::stack<T>::container_type::const_iterator const_iterator;
|
||||
const_iterator begin(void) const { return std::stack<T>::c.begin(); }
|
||||
const_iterator end(void) const { return std::stack<T>::c.end(); }
|
||||
|
||||
private:
|
||||
};
|
Reference in New Issue
Block a user