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/concept_check.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
>
55 // concept requirements
56 __glibcpp_class_requires(_Tp
, _SGIAssignableConcept
);
57 __glibcpp_class_requires(_Sequence
, _BackInsertionSequenceConcept
);
58 typedef typename
_Sequence::value_type _Sequence_value_type
;
59 __glibcpp_class_requires2(_Tp
, _Sequence_value_type
, _SameTypeConcept
);
61 template <class _Tp1
, class _Seq1
>
62 friend bool operator== (const stack
<_Tp1
, _Seq1
>&,
63 const stack
<_Tp1
, _Seq1
>&);
64 template <class _Tp1
, class _Seq1
>
65 friend bool operator< (const stack
<_Tp1
, _Seq1
>&,
66 const stack
<_Tp1
, _Seq1
>&);
68 typedef typename
_Sequence::value_type value_type
;
69 typedef typename
_Sequence::size_type size_type
;
70 typedef _Sequence container_type
;
72 typedef typename
_Sequence::reference reference
;
73 typedef typename
_Sequence::const_reference const_reference
;
78 explicit stack(const _Sequence
& __s
) : c(__s
) {}
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(); }
88 template <class _Tp
, class _Seq
>
89 bool operator==(const stack
<_Tp
,_Seq
>& __x
, const stack
<_Tp
,_Seq
>& __y
)
91 return __x
.c
== __y
.c
;
94 template <class _Tp
, class _Seq
>
95 bool operator<(const stack
<_Tp
,_Seq
>& __x
, const stack
<_Tp
,_Seq
>& __y
)
100 template <class _Tp
, class _Seq
>
101 bool operator!=(const stack
<_Tp
,_Seq
>& __x
, const stack
<_Tp
,_Seq
>& __y
)
103 return !(__x
== __y
);
106 template <class _Tp
, class _Seq
>
107 bool operator>(const stack
<_Tp
,_Seq
>& __x
, const stack
<_Tp
,_Seq
>& __y
)
112 template <class _Tp
, class _Seq
>
113 bool operator<=(const stack
<_Tp
,_Seq
>& __x
, const stack
<_Tp
,_Seq
>& __y
)
118 template <class _Tp
, class _Seq
>
119 bool operator>=(const stack
<_Tp
,_Seq
>& __x
, const stack
<_Tp
,_Seq
>& __y
)
126 #endif /* __SGI_STL_INTERNAL_STACK_H */