5 * This material is provided "as is", with absolutely no warranty expressed
6 * or implied. Any use is at your own risk.
8 * Permission to use or copy this software for any purpose is hereby granted
9 * without fee, provided the above notices are retained on all copies.
10 * Permission to modify the code and to distribute modified code is granted,
11 * provided the above notices are retained, and a notice that the code was
12 * modified is included with the above copyright notice.
16 /* NOTE: This is an internal header file, included by other STL headers.
17 * You should not attempt to use it directly.
20 #ifndef _STLP_PTR_SPECIALIZED_LIST_H
21 #define _STLP_PTR_SPECIALIZED_LIST_H
23 #ifndef _STLP_POINTERS_SPEC_TOOLS_H
24 # include <stl/pointers/_tools.h>
29 #define LIST_IMPL _STLP_PTR_IMPL_NAME(list)
30 #if defined (__BORLANDC__) || defined (__DMC__)
34 #if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
36 _STLP_MOVE_TO_PRIV_NAMESPACE
38 _STLP_EXPORT_TEMPLATE_CLASS _List_node
<void*>;
40 _STLP_MOVE_TO_STD_NAMESPACE
42 _STLP_EXPORT_TEMPLATE_CLASS allocator
<_STLP_PRIV _List_node
<void*> >;
44 _STLP_MOVE_TO_PRIV_NAMESPACE
46 _STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy
<_List_node_base
, _List_node
<void*>, allocator
<_List_node
<void*> > >;
47 _STLP_EXPORT_TEMPLATE_CLASS _List_base
<void*, allocator
<void*> >;
48 _STLP_EXPORT_TEMPLATE_CLASS LIST_IMPL
<void*, allocator
<void*> >;
50 _STLP_MOVE_TO_STD_NAMESPACE
53 #if defined (_STLP_DEBUG)
54 # define list _STLP_NON_DBG_NAME(list)
55 _STLP_MOVE_TO_PRIV_NAMESPACE
58 template <class _Tp
, _STLP_DFL_TMPL_PARAM(_Alloc
, allocator
<_Tp
>) >
60 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (list)
61 : public __stlport_class
<list
<_Tp
, _Alloc
> >
64 typedef _STLP_TYPENAME _STLP_PRIV _StorageType
<_Tp
>::_Type _StorageType
;
65 typedef typename _Alloc_traits
<_StorageType
, _Alloc
>::allocator_type _StorageTypeAlloc
;
66 typedef _STLP_PRIV LIST_IMPL
<_StorageType
, _StorageTypeAlloc
> _Base
;
67 typedef typename
_Base::iterator _BaseIte
;
68 typedef typename
_Base::const_iterator _BaseConstIte
;
69 typedef _STLP_PRIV _CastTraits
<_StorageType
, _Tp
> cast_traits
;
70 typedef list
<_Tp
, _Alloc
> _Self
;
73 typedef _Tp value_type
;
74 typedef value_type
* pointer
;
75 typedef const value_type
* const_pointer
;
76 typedef value_type
& reference
;
77 typedef const value_type
& const_reference
;
78 typedef size_t size_type
;
79 typedef ptrdiff_t difference_type
;
80 _STLP_FORCE_ALLOCATORS(value_type
, _Alloc
)
81 typedef typename _Alloc_traits
<value_type
, _Alloc
>::allocator_type allocator_type
;
82 typedef bidirectional_iterator_tag _Iterator_category
;
84 typedef _STLP_PRIV _List_iterator
<value_type
, _Nonconst_traits
<value_type
> > iterator
;
85 typedef _STLP_PRIV _List_iterator
<value_type
, _Const_traits
<value_type
> > const_iterator
;
87 _STLP_DECLARE_BIDIRECTIONAL_REVERSE_ITERATORS
;
89 allocator_type
get_allocator() const
90 { return _STLP_CONVERT_ALLOCATOR(_M_impl
.get_allocator(), value_type
); }
92 explicit list(const allocator_type
& __a
= allocator_type())
93 : _M_impl(_STLP_CONVERT_ALLOCATOR(__a
, _StorageType
)) {}
95 #if !defined(_STLP_DONT_SUP_DFLT_PARAM)
96 explicit list(size_type __n
, const value_type
& __val
= _STLP_DEFAULT_CONSTRUCTED(value_type
),
98 list(size_type __n
, const value_type
& __val
,
99 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
100 const allocator_type
& __a
= allocator_type())
101 : _M_impl(__n
, cast_traits::to_storage_type_cref(__val
),
102 _STLP_CONVERT_ALLOCATOR(__a
, _StorageType
)) {}
104 #if defined(_STLP_DONT_SUP_DFLT_PARAM)
105 explicit list(size_type __n
)
107 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
109 #if defined (_STLP_MEMBER_TEMPLATES)
110 template <class _InputIterator
>
111 list(_InputIterator __first
, _InputIterator __last
,
112 const allocator_type
& __a _STLP_ALLOCATOR_TYPE_DFL
)
113 # if !defined (_STLP_USE_ITERATOR_WRAPPER)
114 : _M_impl(__first
, __last
, _STLP_CONVERT_ALLOCATOR(__a
, _StorageType
)) {}
116 : _M_impl(_STLP_CONVERT_ALLOCATOR(__a
, _StorageType
)) {
117 insert(begin(), __first
, __last
);
121 # if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
122 template <class _InputIterator
>
123 list(_InputIterator __first
, _InputIterator __last
)
124 # if !defined (_STLP_USE_WRAPPER_ITERATOR)
125 : _M_impl(__first
, __last
) {}
127 { insert(begin(), __first
, __last
); }
131 #else /* _STLP_MEMBER_TEMPLATES */
133 list(const value_type
*__first
, const value_type
*__last
,
134 const allocator_type
& __a
= allocator_type())
135 : _M_impl(cast_traits::to_storage_type_cptr(__first
),
136 cast_traits::to_storage_type_cptr(__last
),
137 _STLP_CONVERT_ALLOCATOR(__a
, _StorageType
)) {}
138 list(const_iterator __first
, const_iterator __last
,
139 const allocator_type
& __a
= allocator_type())
140 : _M_impl(_BaseConstIte(__first
._M_node
), _BaseConstIte(__last
._M_node
),
141 _STLP_CONVERT_ALLOCATOR(__a
, _StorageType
)) {}
143 #endif /* _STLP_MEMBER_TEMPLATES */
145 list(const _Self
& __x
) : _M_impl(__x
._M_impl
) {}
147 #if !defined (_STLP_NO_MOVE_SEMANTIC)
148 list(__move_source
<_Self
> src
)
149 : _M_impl(__move_source
<_Base
>(src
.get()._M_impl
)) {}
152 iterator
begin() { return iterator(_M_impl
.begin()._M_node
); }
153 const_iterator
begin() const { return const_iterator(_M_impl
.begin()._M_node
); }
155 iterator
end() { return iterator(_M_impl
.end()._M_node
); }
156 const_iterator
end() const { return const_iterator(_M_impl
.end()._M_node
); }
158 reverse_iterator
rbegin() { return reverse_iterator(end()); }
159 const_reverse_iterator
rbegin() const { return const_reverse_iterator(end()); }
161 reverse_iterator
rend() { return reverse_iterator(begin()); }
162 const_reverse_iterator
rend() const { return const_reverse_iterator(begin()); }
164 bool empty() const { return _M_impl
.empty(); }
165 size_type
size() const { return _M_impl
.size(); }
166 size_type
max_size() const { return _M_impl
.max_size(); }
168 reference
front() { return *begin(); }
169 const_reference
front() const { return *begin(); }
170 reference
back() { return *(--end()); }
171 const_reference
back() const { return *(--end()); }
173 void swap(_Self
&__x
) { _M_impl
.swap(__x
._M_impl
); }
174 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
175 void _M_swap_workaround(_Self
& __x
) { swap(__x
); }
177 void clear() { _M_impl
.clear(); }
179 #if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
180 iterator
insert(iterator __pos
, const_reference __x
= _STLP_DEFAULT_CONSTRUCTED(value_type
))
182 iterator
insert(iterator __pos
, const_reference __x
)
183 #endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
184 { return iterator(_M_impl
.insert(_BaseIte(__pos
._M_node
),
185 cast_traits::to_storage_type_cref(__x
))._M_node
); }
187 #if defined (_STLP_MEMBER_TEMPLATES)
188 # if defined (_STLP_USE_ITERATOR_WRAPPER)
190 template <class _Integer
>
191 void _M_insert_dispatch(iterator __pos
, _Integer __n
, _Integer __val
,
193 { _M_impl
.insert(_BaseIte(__pos
._M_node
), __n
, __val
); }
195 template <class _InputIterator
>
196 void _M_insert_dispatch(iterator __pos
,
197 _InputIterator __first
, _InputIterator __last
,
198 const __false_type
&) {
199 _M_impl
.insert(_BaseIte(__pos
._M_node
),
200 _STLP_TYPENAME _STLP_PRIV _IteWrapper
<_StorageType
, _Tp
, _InputIterator
>::_Ite(__first
),
201 _STLP_TYPENAME _STLP_PRIV _IteWrapper
<_StorageType
, _Tp
, _InputIterator
>::_Ite(__last
));
207 template <class _InputIterator
>
208 void insert(iterator __pos
, _InputIterator __first
, _InputIterator __last
) {
209 # if defined (_STLP_USE_ITERATOR_WRAPPER)
210 // Check whether it's an integral type. If so, it's not an iterator.
211 typedef typename _IsIntegral
<_InputIterator
>::_Ret _Integral
;
212 _M_insert_dispatch(__pos
, __first
, __last
, _Integral());
214 _M_impl
.insert(_BaseIte(__pos
._M_node
), __first
, __last
);
217 #else /* _STLP_MEMBER_TEMPLATES */
218 void insert(iterator __pos
, const value_type
*__first
, const value_type
*__last
)
219 { _M_impl
.insert(_BaseIte(__pos
._M_node
), cast_traits::to_storage_type_cptr(__first
),
220 cast_traits::to_storage_type_cptr(__last
)); }
221 void insert(iterator __pos
, const_iterator __first
, const_iterator __last
)
222 { _M_impl
.insert(_BaseIte(__pos
._M_node
), _BaseConstIte(__first
._M_node
), _BaseConstIte(__last
._M_node
)); }
223 #endif /* _STLP_MEMBER_TEMPLATES */
225 void insert(iterator __pos
, size_type __n
, const value_type
& __x
)
226 { _M_impl
.insert(_BaseIte(__pos
._M_node
), __n
, cast_traits::to_storage_type_cref(__x
)); }
228 void push_front(const value_type
& __x
) { _M_impl
.push_front(cast_traits::to_storage_type_cref(__x
)); }
229 void push_back(const value_type
& __x
) { _M_impl
.push_back(cast_traits::to_storage_type_cref(__x
)); }
231 #if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
232 iterator
insert(iterator __pos
) { return iterator(_M_impl
.insert(__pos
._M_node
)._M_node
); }
233 void push_front() { _M_impl
.push_front();}
234 void push_back() { _M_impl
.push_back();}
235 # endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
237 iterator
erase(iterator __pos
)
238 { return iterator(_M_impl
.erase(_BaseIte(__pos
._M_node
))._M_node
); }
239 iterator
erase(iterator __first
, iterator __last
)
240 { return iterator(_M_impl
.erase(_BaseIte(__first
._M_node
), _BaseIte(__last
._M_node
))._M_node
); }
242 #if !defined(_STLP_DONT_SUP_DFLT_PARAM)
243 void resize(size_type __new_size
, const value_type
& __x
= _STLP_DEFAULT_CONSTRUCTED(value_type
))
245 void resize(size_type __new_size
) { _M_impl
.resize(__new_size
); }
246 void resize(size_type __new_size
, const value_type
& __x
)
247 #endif /*!_STLP_DONT_SUP_DFLT_PARAM*/
248 {_M_impl
.resize(__new_size
, cast_traits::to_storage_type_cref(__x
));}
250 void pop_front() { _M_impl
.pop_front(); }
251 void pop_back() { _M_impl
.pop_back(); }
253 _Self
& operator=(const _Self
& __x
)
254 { _M_impl
= __x
._M_impl
; return *this; }
255 void assign(size_type __n
, const value_type
& __val
)
256 { _M_impl
.assign(__n
, cast_traits::to_storage_type_cref(__val
)); }
258 #if defined (_STLP_MEMBER_TEMPLATES)
259 # if defined (_STLP_USE_ITERATOR_WRAPPER)
261 template <class _Integer
>
262 void _M_assign_dispatch(_Integer __n
, _Integer __val
, const __true_type
&)
263 { _M_impl
.assign(__n
, __val
); }
265 template <class _InputIterator
>
266 void _M_assign_dispatch(_InputIterator __first
, _InputIterator __last
,
267 const __false_type
&) {
268 _M_impl
.assign(_STLP_TYPENAME _STLP_PRIV _IteWrapper
<_StorageType
, _Tp
, _InputIterator
>::_Ite(__first
),
269 _STLP_TYPENAME _STLP_PRIV _IteWrapper
<_StorageType
, _Tp
, _InputIterator
>::_Ite(__last
));
275 template <class _InputIterator
>
276 void assign(_InputIterator __first
, _InputIterator __last
) {
277 # if defined (_STLP_USE_ITERATOR_WRAPPER)
278 typedef typename _IsIntegral
<_InputIterator
>::_Ret _Integral
;
279 _M_assign_dispatch(__first
, __last
, _Integral());
281 _M_impl
.assign(__first
, __last
);
285 void assign(const value_type
*__first
, const value_type
*__last
) {
286 _M_impl
.assign(cast_traits::to_storage_type_cptr(__first
),
287 cast_traits::to_storage_type_cptr(__last
));
289 void assign(const_iterator __first
, const_iterator __last
)
290 { _M_impl
.assign(_BaseConstIte(__first
._M_node
), _BaseConstIte(__last
._M_node
)); }
293 void splice(iterator __pos
, _Self
& __x
)
294 { _M_impl
.splice(_BaseIte(__pos
._M_node
), __x
._M_impl
); }
295 void splice(iterator __pos
, _Self
& __x
, iterator __i
)
296 { _M_impl
.splice(_BaseIte(__pos
._M_node
), __x
._M_impl
, _BaseIte(__i
._M_node
)); }
297 void splice(iterator __pos
, _Self
& __x
, iterator __first
, iterator __last
)
298 { _M_impl
.splice(_BaseIte(__pos
._M_node
), __x
._M_impl
,
299 _BaseIte(__first
._M_node
), _BaseIte(__last
._M_node
)); }
301 void remove(const_reference __val
)
302 { _M_impl
.remove(cast_traits::to_storage_type_cref(__val
)); }
303 void unique() { _M_impl
.unique(); }
304 void merge(_Self
& __x
) { _M_impl
.merge(__x
._M_impl
); }
305 void reverse() { _M_impl
.reverse(); }
306 void sort() { _M_impl
.sort(); }
308 #if defined (_STLP_MEMBER_TEMPLATES)
309 template <class _Predicate
>
310 void remove_if(_Predicate __pred
)
311 { _M_impl
.remove_if(_STLP_PRIV _UnaryPredWrapper
<_StorageType
, _Tp
, _Predicate
>(__pred
)); }
312 template <class _BinaryPredicate
>
313 void unique(_BinaryPredicate __bin_pred
)
314 { _M_impl
.unique(_STLP_PRIV _BinaryPredWrapper
<_StorageType
, _Tp
, _BinaryPredicate
>(__bin_pred
)); }
316 template <class _StrictWeakOrdering
>
317 void merge(_Self
&__x
, _StrictWeakOrdering __comp
)
318 { _M_impl
.merge(__x
._M_impl
, _STLP_PRIV _BinaryPredWrapper
<_StorageType
, _Tp
, _StrictWeakOrdering
>(__comp
)); }
320 template <class _StrictWeakOrdering
>
321 void sort(_StrictWeakOrdering __comp
)
322 { _M_impl
.sort(_STLP_PRIV _BinaryPredWrapper
<_StorageType
, _Tp
, _StrictWeakOrdering
>(__comp
)); }
323 #endif /* _STLP_MEMBER_TEMPLATES */
331 _STLP_MOVE_TO_STD_NAMESPACE
335 #if defined (__BORLANDC__) || defined (__DMC__)
341 #endif /* _STLP_PTR_SPECIALIZED_LIST_H */