From b721bc1aede3b3211302d103a1de1019c732ce74 Mon Sep 17 00:00:00 2001 From: obrien Date: Sat, 16 Oct 1999 03:52:48 +0000 Subject: Virgin import of GCC 2.95.1's libstdc++ --- contrib/libstdc++/stl/stl_stack.h | 73 +++++++++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 19 deletions(-) (limited to 'contrib/libstdc++/stl/stl_stack.h') diff --git a/contrib/libstdc++/stl/stl_stack.h b/contrib/libstdc++/stl/stl_stack.h index d380e81..2a04b21 100644 --- a/contrib/libstdc++/stl/stl_stack.h +++ b/contrib/libstdc++/stl/stl_stack.h @@ -34,39 +34,74 @@ __STL_BEGIN_NAMESPACE #ifndef __STL_LIMITED_DEFAULT_TEMPLATES -template > +template > #else -template +template #endif class stack { friend bool operator== __STL_NULL_TMPL_ARGS (const stack&, const stack&); friend bool operator< __STL_NULL_TMPL_ARGS (const stack&, const stack&); public: - typedef typename Sequence::value_type value_type; - typedef typename Sequence::size_type size_type; - typedef typename Sequence::reference reference; - typedef typename Sequence::const_reference const_reference; + typedef typename _Sequence::value_type value_type; + typedef typename _Sequence::size_type size_type; + typedef _Sequence container_type; + + typedef typename _Sequence::reference reference; + typedef typename _Sequence::const_reference const_reference; protected: - Sequence c; + _Sequence _M_c; public: - bool empty() const { return c.empty(); } - size_type size() const { return c.size(); } - reference top() { return c.back(); } - const_reference top() const { return c.back(); } - void push(const value_type& x) { c.push_back(x); } - void pop() { c.pop_back(); } + stack() : _M_c() {} + explicit stack(const _Sequence& __s) : _M_c(__s) {} + + bool empty() const { return _M_c.empty(); } + size_type size() const { return _M_c.size(); } + reference top() { return _M_c.back(); } + const_reference top() const { return _M_c.back(); } + void push(const value_type& __x) { _M_c.push_back(__x); } + void pop() { _M_c.pop_back(); } }; -template -bool operator==(const stack& x, const stack& y) { - return x.c == y.c; +template +bool operator==(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) +{ + return __x._M_c == __y._M_c; +} + +template +bool operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) +{ + return __x._M_c < __y._M_c; +} + +#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER + +template +bool operator!=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) +{ + return !(__x == __y); +} + +template +bool operator>(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) +{ + return __y < __x; } -template -bool operator<(const stack& x, const stack& y) { - return x.c < y.c; +template +bool operator<=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) +{ + return !(__y < __x); } +template +bool operator>=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y) +{ + return !(__x < __y); +} + +#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */ + __STL_END_NAMESPACE #endif /* __SGI_STL_INTERNAL_STACK_H */ -- cgit v1.1