Initial import from FreeBSD RELENG_4:
[dragonfly.git] / contrib / libstdc++ / stl / stl_stack.h
1 /*
2  *
3  * Copyright (c) 1994
4  * Hewlett-Packard Company
5  *
6  * Permission to use, copy, modify, distribute and sell this software
7  * and its documentation for any purpose is hereby granted without fee,
8  * provided that the above copyright notice appear in all copies and
9  * that both that copyright notice and this permission notice appear
10  * in supporting documentation.  Hewlett-Packard Company makes no
11  * representations about the suitability of this software for any
12  * purpose.  It is provided "as is" without express or implied warranty.
13  *
14  *
15  * Copyright (c) 1996,1997
16  * Silicon Graphics Computer Systems, Inc.
17  *
18  * Permission to use, copy, modify, distribute and sell this software
19  * and its documentation for any purpose is hereby granted without fee,
20  * provided that the above copyright notice appear in all copies and
21  * that both that copyright notice and this permission notice appear
22  * in supporting documentation.  Silicon Graphics makes no
23  * representations about the suitability of this software for any
24  * purpose.  It is provided "as is" without express or implied warranty.
25  */
26
27 /* NOTE: This is an internal header file, included by other STL headers.
28  *   You should not attempt to use it directly.
29  */
30
31 #ifndef __SGI_STL_INTERNAL_STACK_H
32 #define __SGI_STL_INTERNAL_STACK_H
33
34 __STL_BEGIN_NAMESPACE
35
36 #ifndef __STL_LIMITED_DEFAULT_TEMPLATES
37 template <class _Tp, class _Sequence = deque<_Tp> >
38 #else
39 template <class _Tp, class _Sequence>
40 #endif
41 class stack {
42   friend bool operator== __STL_NULL_TMPL_ARGS (const stack&, const stack&);
43   friend bool operator< __STL_NULL_TMPL_ARGS (const stack&, const stack&);
44 public:
45   typedef typename _Sequence::value_type      value_type;
46   typedef typename _Sequence::size_type       size_type;
47   typedef          _Sequence                  container_type;
48
49   typedef typename _Sequence::reference       reference;
50   typedef typename _Sequence::const_reference const_reference;
51 protected:
52   _Sequence _M_c;
53 public:
54   stack() : _M_c() {}
55   explicit stack(const _Sequence& __s) : _M_c(__s) {}
56
57   bool empty() const { return _M_c.empty(); }
58   size_type size() const { return _M_c.size(); }
59   reference top() { return _M_c.back(); }
60   const_reference top() const { return _M_c.back(); }
61   void push(const value_type& __x) { _M_c.push_back(__x); }
62   void pop() { _M_c.pop_back(); }
63 };
64
65 template <class _Tp, class _Seq>
66 bool operator==(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
67 {
68   return __x._M_c == __y._M_c;
69 }
70
71 template <class _Tp, class _Seq>
72 bool operator<(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
73 {
74   return __x._M_c < __y._M_c;
75 }
76
77 #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
78
79 template <class _Tp, class _Seq>
80 bool operator!=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
81 {
82   return !(__x == __y);
83 }
84
85 template <class _Tp, class _Seq>
86 bool operator>(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
87 {
88   return __y < __x;
89 }
90
91 template <class _Tp, class _Seq>
92 bool operator<=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
93 {
94   return !(__y < __x);
95 }
96
97 template <class _Tp, class _Seq>
98 bool operator>=(const stack<_Tp,_Seq>& __x, const stack<_Tp,_Seq>& __y)
99 {
100   return !(__x < __y);
101 }
102
103 #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
104
105 __STL_END_NAMESPACE
106
107 #endif /* __SGI_STL_INTERNAL_STACK_H */
108
109 // Local Variables:
110 // mode:C++
111 // End: