4 * Hewlett-Packard Company
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.
15 * Copyright (c) 1996,1997
16 * Silicon Graphics Computer Systems, Inc.
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.
27 /* NOTE: This is an internal header file, included by other STL headers.
28 * You should not attempt to use it directly.
31 #ifndef __SGI_STL_INTERNAL_STACK_H
32 #define __SGI_STL_INTERNAL_STACK_H
34 #include <bits/sequence_concepts.h>
39 // Forward declarations of operators == and <, needed for friend declaration.
42 class _Sequence
= deque
<_Tp
> >
45 template <class _Tp
, class _Seq
>
46 bool operator==(const stack
<_Tp
,_Seq
>& __x
, const stack
<_Tp
,_Seq
>& __y
);
48 template <class _Tp
, class _Seq
>
49 bool operator<(const stack
<_Tp
,_Seq
>& __x
, const stack
<_Tp
,_Seq
>& __y
);
52 template <class _Tp
, class _Sequence
>
57 __STL_CLASS_REQUIRES(_Tp
, _Assignable
);
58 __STL_CLASS_REQUIRES(_Sequence
, _BackInsertionSequence
);
59 typedef typename
_Sequence::value_type _Sequence_value_type
;
60 __STL_CLASS_REQUIRES_SAME_TYPE(_Tp
, _Sequence_value_type
);
63 template <class _Tp1
, class _Seq1
>
64 friend bool operator== (const stack
<_Tp1
, _Seq1
>&,
65 const stack
<_Tp1
, _Seq1
>&);
66 template <class _Tp1
, class _Seq1
>
67 friend bool operator< (const stack
<_Tp1
, _Seq1
>&,
68 const stack
<_Tp1
, _Seq1
>&);
70 typedef typename
_Sequence::value_type value_type
;
71 typedef typename
_Sequence::size_type size_type
;
72 typedef _Sequence container_type
;
74 typedef typename
_Sequence::reference reference
;
75 typedef typename
_Sequence::const_reference const_reference
;
80 explicit stack(const _Sequence
& __s
) : c(__s
) {}
82 bool empty() const { return c
.empty(); }
83 size_type
size() const { return c
.size(); }
84 reference
top() { return c
.back(); }
85 const_reference
top() const { return c
.back(); }
86 void push(const value_type
& __x
) { c
.push_back(__x
); }
87 void pop() { c
.pop_back(); }
90 template <class _Tp
, class _Seq
>
91 bool operator==(const stack
<_Tp
,_Seq
>& __x
, const stack
<_Tp
,_Seq
>& __y
)
93 return __x
.c
== __y
.c
;
96 template <class _Tp
, class _Seq
>
97 bool operator<(const stack
<_Tp
,_Seq
>& __x
, const stack
<_Tp
,_Seq
>& __y
)
102 template <class _Tp
, class _Seq
>
103 bool operator!=(const stack
<_Tp
,_Seq
>& __x
, const stack
<_Tp
,_Seq
>& __y
)
105 return !(__x
== __y
);
108 template <class _Tp
, class _Seq
>
109 bool operator>(const stack
<_Tp
,_Seq
>& __x
, const stack
<_Tp
,_Seq
>& __y
)
114 template <class _Tp
, class _Seq
>
115 bool operator<=(const stack
<_Tp
,_Seq
>& __x
, const stack
<_Tp
,_Seq
>& __y
)
120 template <class _Tp
, class _Seq
>
121 bool operator>=(const stack
<_Tp
,_Seq
>& __x
, const stack
<_Tp
,_Seq
>& __y
)
128 #endif /* __SGI_STL_INTERNAL_STACK_H */