separate stack hpp and stack tpp
This commit is contained in:
72
templates/stack.tpp
Normal file
72
templates/stack.tpp
Normal file
@@ -0,0 +1,72 @@
|
||||
|
||||
#define ST_TPL template <class T, class Container>
|
||||
#define ST stack<T, Container>
|
||||
|
||||
namespace ft {
|
||||
|
||||
|
||||
/************
|
||||
* copliens :
|
||||
************/
|
||||
// constructors ------------------------------
|
||||
ST_TPL ST::
|
||||
stack(const container_type& cont)
|
||||
: c(cont) {}
|
||||
|
||||
|
||||
/**********************
|
||||
* overload functions :
|
||||
**********************/
|
||||
// empty -------------------------------------
|
||||
ST_TPL bool ST::
|
||||
empty() const { return c.empty(); }
|
||||
// size --------------------------------------
|
||||
ST_TPL typename ST::size_type ST::
|
||||
size() const { return c.size(); }
|
||||
// top ---------------------------------------
|
||||
ST_TPL typename ST::value_type& ST::
|
||||
top() { return c.back(); }
|
||||
ST_TPL const typename ST::value_type& ST::
|
||||
top() const { return c.back(); }
|
||||
// push --------------------------------------
|
||||
ST_TPL void ST::
|
||||
push(const value_type& value) { c.push_back(value); }
|
||||
// pop ---------------------------------------
|
||||
ST_TPL void ST::
|
||||
pop() { c.pop_back(); }
|
||||
|
||||
|
||||
/************************
|
||||
* non-member functions :
|
||||
************************/
|
||||
// operator == -------------------------------
|
||||
ST_TPL bool
|
||||
operator==(const stack<T, Container>& lhs, const stack<T, Container>& rhs)
|
||||
{ return lhs.c == rhs.c; }
|
||||
// operator != -------------------------------
|
||||
ST_TPL bool
|
||||
operator!=(const stack<T, Container>& lhs, const stack<T, Container>& rhs)
|
||||
{ return lhs.c != rhs.c; }
|
||||
// operator < --------------------------------
|
||||
ST_TPL bool
|
||||
operator<(const stack<T, Container>& lhs, const stack<T, Container>& rhs)
|
||||
{ return lhs.c < rhs.c; }
|
||||
// operator > --------------------------------
|
||||
ST_TPL bool
|
||||
operator>(const stack<T, Container>& lhs, const stack<T, Container>& rhs)
|
||||
{ return lhs.c > rhs.c; }
|
||||
// operator <= -------------------------------
|
||||
ST_TPL bool
|
||||
operator<=(const stack<T, Container>& lhs, const stack<T, Container>& rhs)
|
||||
{ return lhs.c <= rhs.c; }
|
||||
// operator >= -------------------------------
|
||||
ST_TPL bool
|
||||
operator>=(const stack<T, Container>& lhs, const stack<T, Container>& rhs)
|
||||
{ return lhs.c >= rhs.c; }
|
||||
|
||||
|
||||
} // namespace ft
|
||||
|
||||
#undef VT
|
||||
#undef VT_TPL
|
||||
|
||||
Reference in New Issue
Block a user