]> git.buserror.net Git - polintos/scott/priv.git/blob - include/c++/stl/stl/_stack.h
minor doc updates
[polintos/scott/priv.git] / include / c++ / stl / stl / _stack.h
1 /*
2  *
3  * Copyright (c) 1994
4  * Hewlett-Packard Company
5  *
6  * Copyright (c) 1996,1997
7  * Silicon Graphics Computer Systems, Inc.
8  *
9  * Copyright (c) 1997
10  * Moscow Center for SPARC Technology
11  *
12  * Copyright (c) 1999
13  * Boris Fomitchev
14  *
15  * This material is provided "as is", with absolutely no warranty expressed
16  * or implied. Any use is at your own risk.
17  *
18  * Permission to use or copy this software for any purpose is hereby granted
19  * without fee, provided the above notices are retained on all copies.
20  * Permission to modify the code and to distribute modified code is granted,
21  * provided the above notices are retained, and a notice that the code was
22  * modified is included with the above copyright notice.
23  *
24  */
25
26 /* NOTE: This is an internal header file, included by other STL headers.
27  *   You should not attempt to use it directly.
28  */
29
30 #ifndef _STLP_INTERNAL_STACK_H
31 #define _STLP_INTERNAL_STACK_H
32
33 #ifndef _STLP_INTERNAL_DEQUE_H
34 #  include <stl/_deque.h>
35 #endif
36
37 _STLP_BEGIN_NAMESPACE
38
39 #if !defined ( _STLP_LIMITED_DEFAULT_TEMPLATES )
40 template <class _Tp, class _Sequence = deque<_Tp> >
41 #elif defined ( _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS )
42 #  define _STLP_STACK_ARGS _Tp
43 template <class _Tp>
44 #else
45 template <class _Tp, class _Sequence>
46 #endif
47 class stack
48 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
49 #  if defined (_STLP_STACK_ARGS)
50             : public __stlport_class<stack<_Tp> >
51 #  else
52             : public __stlport_class<stack<_Tp, _Sequence> >
53 #  endif
54 #endif
55 {
56 #ifdef _STLP_STACK_ARGS
57   typedef deque<_Tp> _Sequence;
58   typedef stack<_Tp> _Self;
59 #else
60   typedef stack<_Tp, _Sequence> _Self;
61 #endif
62
63 public:
64   typedef typename _Sequence::value_type      value_type;
65   typedef typename _Sequence::size_type       size_type;
66   typedef          _Sequence                  container_type;
67
68   typedef typename _Sequence::reference       reference;
69   typedef typename _Sequence::const_reference const_reference;
70 protected:
71   //c is a Standard name (23.2.3.3), do no make it STLport naming convention compliant.
72   _Sequence c;
73 public:
74   stack() : c() {}
75   explicit stack(const _Sequence& __s) : c(__s) {}
76
77   stack(__move_source<_Self> src)
78     : c(_STLP_PRIV _AsMoveSource(src.get().c)) {}
79
80   bool empty() const { return c.empty(); }
81   size_type size() const { return c.size(); }
82   reference top() { return c.back(); }
83   const_reference top() const { return c.back(); }
84   void push(const value_type& __x) { c.push_back(__x); }
85   void pop() { c.pop_back(); }
86   const _Sequence& _Get_s() const { return c; }
87 };
88
89 #ifndef _STLP_STACK_ARGS
90 #  define _STLP_STACK_ARGS _Tp, _Sequence
91 #  define _STLP_STACK_HEADER_ARGS class _Tp, class _Sequence
92 #else
93 #  define _STLP_STACK_HEADER_ARGS class _Tp
94 #endif
95
96 template < _STLP_STACK_HEADER_ARGS >
97 inline bool _STLP_CALL  operator==(const stack< _STLP_STACK_ARGS >& __x,
98                                    const stack< _STLP_STACK_ARGS >& __y)
99 { return __x._Get_s() == __y._Get_s(); }
100
101 template < _STLP_STACK_HEADER_ARGS >
102 inline bool _STLP_CALL  operator<(const stack< _STLP_STACK_ARGS >& __x,
103                                   const stack< _STLP_STACK_ARGS >& __y)
104 { return __x._Get_s() < __y._Get_s(); }
105
106 _STLP_RELOPS_OPERATORS(template < _STLP_STACK_HEADER_ARGS >, stack< _STLP_STACK_ARGS >)
107
108 #undef _STLP_STACK_ARGS
109 #undef _STLP_STACK_HEADER_ARGS
110
111 #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
112 template <class _Tp, class _Sequence>
113 struct __move_traits<stack<_Tp, _Sequence> > :
114   _STLP_PRIV __move_traits_aux<_Sequence>
115 {};
116 #endif
117
118 _STLP_END_NAMESPACE
119
120 #endif /* _STLP_INTERNAL_STACK_H */
121
122 // Local Variables:
123 // mode:C++
124 // End: