1.1 --- a/epoc32/include/stdapis/stlportv5/stl/_deque.c Wed Mar 31 12:27:01 2010 +0100
1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_deque.c Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -10,13 +10,13 @@
1.4 * Copyright (c) 1997
1.5 * Moscow Center for SPARC Technology
1.6 *
1.7 - * Copyright (c) 1999
1.8 + * Copyright (c) 1999
1.9 * Boris Fomitchev
1.10 *
1.11 * This material is provided "as is", with absolutely no warranty expressed
1.12 * or implied. Any use is at your own risk.
1.13 *
1.14 - * Permission to use or copy this software for any purpose is hereby granted
1.15 + * Permission to use or copy this software for any purpose is hereby granted
1.16 * without fee, provided the above notices are retained on all copies.
1.17 * Permission to modify the code and to distribute modified code is granted,
1.18 * provided the above notices are retained, and a notice that the code was
1.19 @@ -24,91 +24,87 @@
1.20 *
1.21 */
1.22 #ifndef _STLP_DEQUE_C
1.23 -# define _STLP_DEQUE_C
1.24 +#define _STLP_DEQUE_C
1.25
1.26 -# ifndef _STLP_INTERNAL_DEQUE_H
1.27 +#ifndef _STLP_INTERNAL_DEQUE_H
1.28 # include <stl/_deque.h>
1.29 -# endif
1.30 +#endif
1.31
1.32 _STLP_BEGIN_NAMESPACE
1.33
1.34 +_STLP_MOVE_TO_PRIV_NAMESPACE
1.35 +
1.36 // Non-inline member functions from _Deque_base.
1.37
1.38 template <class _Tp, class _Alloc >
1.39 _Deque_base<_Tp,_Alloc >::~_Deque_base() {
1.40 if (_M_map._M_data) {
1.41 - if (_M_start._M_node) {
1.42 - _M_destroy_nodes(_M_start._M_node, this->_M_finish._M_node + 1);
1.43 - }
1.44 + _M_destroy_nodes(_M_start._M_node, this->_M_finish._M_node + 1);
1.45 _M_map.deallocate(_M_map._M_data, _M_map_size._M_data);
1.46 }
1.47 }
1.48
1.49 template <class _Tp, class _Alloc >
1.50 -void
1.51 -_Deque_base<_Tp,_Alloc>::_M_initialize_map(size_t __num_elements)
1.52 -{
1.53 - size_t __num_nodes =
1.54 - __num_elements / this->buffer_size() + 1 ;
1.55 +void _Deque_base<_Tp,_Alloc>::_M_initialize_map(size_t __num_elements) {
1.56 + size_t __num_nodes = __num_elements / this->buffer_size() + 1 ;
1.57
1.58 _M_map_size._M_data = (max)((size_t) _S_initial_map_size, __num_nodes + 2);
1.59 _M_map._M_data = _M_map.allocate(_M_map_size._M_data);
1.60
1.61 _Tp** __nstart = _M_map._M_data + (_M_map_size._M_data - __num_nodes) / 2;
1.62 _Tp** __nfinish = __nstart + __num_nodes;
1.63 -
1.64 +
1.65 _STLP_TRY {
1.66 _M_create_nodes(__nstart, __nfinish);
1.67 }
1.68 - _STLP_UNWIND((_M_map.deallocate(_M_map._M_data, _M_map_size._M_data),
1.69 - _M_map._M_data = 0, _M_map_size._M_data = 0));
1.70 + _STLP_UNWIND((_M_map.deallocate(_M_map._M_data, _M_map_size._M_data),
1.71 + _M_map._M_data = 0, _M_map_size._M_data = 0))
1.72 _M_start._M_set_node(__nstart);
1.73 this->_M_finish._M_set_node(__nfinish - 1);
1.74 _M_start._M_cur = _M_start._M_first;
1.75 - this->_M_finish._M_cur = this->_M_finish._M_first +
1.76 - __num_elements % this->buffer_size();
1.77 + this->_M_finish._M_cur = this->_M_finish._M_first + __num_elements % this->buffer_size();
1.78 }
1.79
1.80 template <class _Tp, class _Alloc >
1.81 -void
1.82 -_Deque_base<_Tp,_Alloc>::_M_create_nodes(_Tp** __nstart,
1.83 - _Tp** __nfinish)
1.84 -{
1.85 - _Tp** _STLP_LEAVE_VOLATILE __cur = 0;
1.86 +void _Deque_base<_Tp,_Alloc>::_M_create_nodes(_Tp** __nstart,
1.87 + _Tp** __nfinish) {
1.88 + _Tp** __cur = __nstart;
1.89 _STLP_TRY {
1.90 - for (__cur = __nstart; __cur < __nfinish; ++__cur)
1.91 + for (; __cur < __nfinish; ++__cur)
1.92 *__cur = _M_map_size.allocate(this->buffer_size());
1.93 }
1.94 - _STLP_UNWIND(_M_destroy_nodes(__nstart, __cur));
1.95 + _STLP_UNWIND(_M_destroy_nodes(__nstart, __cur))
1.96 }
1.97
1.98 template <class _Tp, class _Alloc >
1.99 -void
1.100 -_Deque_base<_Tp,_Alloc>::_M_destroy_nodes(_Tp** __nstart,
1.101 - _Tp** __nfinish)
1.102 -{
1.103 +void _Deque_base<_Tp,_Alloc>::_M_destroy_nodes(_Tp** __nstart,
1.104 + _Tp** __nfinish) {
1.105 for (_Tp** __n = __nstart; __n < __nfinish; ++__n)
1.106 _M_map_size.deallocate(*__n, this->buffer_size());
1.107 }
1.108
1.109 +#if defined (_STLP_USE_PTR_SPECIALIZATIONS)
1.110 +# define deque _STLP_PTR_IMPL_NAME(deque)
1.111 +#elif defined (_STLP_DEBUG)
1.112 +# define deque _STLP_NON_DBG_NAME(deque)
1.113 +#else
1.114 +_STLP_MOVE_TO_STD_NAMESPACE
1.115 +#endif
1.116
1.117 -
1.118 -// Non-inline member functions
1.119 -
1.120 -# if defined ( _STLP_NESTED_TYPE_PARAM_BUG )
1.121 -// qualified references
1.122 -# define __iterator__ _Deque_iterator<_Tp, _Nonconst_traits<_Tp> >
1.123 -# define const_iterator _Deque_iterator<_Tp, _Const_traits<_Tp> >
1.124 -# define iterator __iterator__
1.125 -# define size_type size_t
1.126 -# define value_type _Tp
1.127 -# else
1.128 -# define __iterator__ _STLP_TYPENAME_ON_RETURN_TYPE __deque__<_Tp, _Alloc>::iterator
1.129 -# endif
1.130 +#if defined (_STLP_NESTED_TYPE_PARAM_BUG)
1.131 +// qualified references
1.132 +# define __iterator__ _Deque_iterator<_Tp, _Nonconst_traits<_Tp> >
1.133 +# define const_iterator _Deque_iterator<_Tp, _Const_traits<_Tp> >
1.134 +# define iterator __iterator__
1.135 +# define size_type size_t
1.136 +# define value_type _Tp
1.137 +#else
1.138 +# define __iterator__ _STLP_TYPENAME_ON_RETURN_TYPE deque<_Tp, _Alloc>::iterator
1.139 +#endif
1.140
1.141 template <class _Tp, class _Alloc >
1.142 -__deque__<_Tp, _Alloc >&
1.143 -__deque__<_Tp, _Alloc >::operator= (const __deque__<_Tp, _Alloc >& __x) {
1.144 +deque<_Tp, _Alloc >&
1.145 +deque<_Tp, _Alloc >::operator= (const deque<_Tp, _Alloc >& __x) {
1.146 const size_type __len = size();
1.147 if (&__x != this) {
1.148 if (__len >= __x.size())
1.149 @@ -120,19 +116,17 @@
1.150 }
1.151 }
1.152 return *this;
1.153 -}
1.154 +}
1.155
1.156 template <class _Tp, class _Alloc >
1.157 -void
1.158 -__deque__<_Tp, _Alloc >::_M_fill_insert(iterator __pos,
1.159 - size_type __n, const value_type& __x)
1.160 -{
1.161 +void deque<_Tp, _Alloc >::_M_fill_insert(iterator __pos,
1.162 + size_type __n, const value_type& __x) {
1.163 if (__pos._M_cur == this->_M_start._M_cur) {
1.164 iterator __new_start = _M_reserve_elements_at_front(__n);
1.165 _STLP_TRY {
1.166 uninitialized_fill(__new_start, this->_M_start, __x);
1.167 }
1.168 - _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node));
1.169 + _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
1.170 this->_M_start = __new_start;
1.171 }
1.172 else if (__pos._M_cur == this->_M_finish._M_cur) {
1.173 @@ -140,115 +134,221 @@
1.174 _STLP_TRY {
1.175 uninitialized_fill(this->_M_finish, __new_finish, __x);
1.176 }
1.177 - _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node+1, __new_finish._M_node+1));
1.178 + _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node+1, __new_finish._M_node+1))
1.179 this->_M_finish = __new_finish;
1.180 }
1.181 - else
1.182 - _M_insert_aux(__pos, __n, __x);
1.183 + else
1.184 + _M_fill_insert_aux(__pos, __n, __x, _Movable());
1.185 }
1.186
1.187 -#ifndef _STLP_MEMBER_TEMPLATES
1.188 +#if !defined (_STLP_MEMBER_TEMPLATES)
1.189
1.190 template <class _Tp, class _Alloc >
1.191 -void __deque__<_Tp, _Alloc>::insert(iterator __pos,
1.192 - const value_type* __first,
1.193 - const value_type* __last) {
1.194 +void deque<_Tp, _Alloc>::insert(iterator __pos,
1.195 + const value_type* __first, const value_type* __last) {
1.196 size_type __n = __last - __first;
1.197 if (__pos._M_cur == this->_M_start._M_cur) {
1.198 iterator __new_start = _M_reserve_elements_at_front(__n);
1.199 _STLP_TRY {
1.200 - uninitialized_copy(__first, __last, __new_start);
1.201 + _STLP_PRIV __ucopy(__first, __last, __new_start);
1.202 }
1.203 - _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node));
1.204 + _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
1.205 this->_M_start = __new_start;
1.206 }
1.207 else if (__pos._M_cur == this->_M_finish._M_cur) {
1.208 iterator __new_finish = _M_reserve_elements_at_back(__n);
1.209 _STLP_TRY {
1.210 - uninitialized_copy(__first, __last, this->_M_finish);
1.211 + _STLP_PRIV __ucopy(__first, __last, this->_M_finish);
1.212 }
1.213 - _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1,
1.214 - __new_finish._M_node + 1));
1.215 + _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1,
1.216 + __new_finish._M_node + 1))
1.217 this->_M_finish = __new_finish;
1.218 }
1.219 else
1.220 - _M_insert_aux(__pos, __first, __last, __n);
1.221 + _M_insert_range_aux(__pos, __first, __last, __n, _Movable());
1.222 }
1.223
1.224 template <class _Tp, class _Alloc >
1.225 -void __deque__<_Tp,_Alloc>::insert(iterator __pos,
1.226 - const_iterator __first,
1.227 - const_iterator __last)
1.228 -{
1.229 +void deque<_Tp,_Alloc>::insert(iterator __pos,
1.230 + const_iterator __first, const_iterator __last) {
1.231 size_type __n = __last - __first;
1.232 if (__pos._M_cur == this->_M_start._M_cur) {
1.233 iterator __new_start = _M_reserve_elements_at_front(__n);
1.234 _STLP_TRY {
1.235 - uninitialized_copy(__first, __last, __new_start);
1.236 + _STLP_PRIV __ucopy(__first, __last, __new_start);
1.237 }
1.238 - _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node));
1.239 + _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
1.240 this->_M_start = __new_start;
1.241 }
1.242 else if (__pos._M_cur == this->_M_finish._M_cur) {
1.243 iterator __new_finish = _M_reserve_elements_at_back(__n);
1.244 _STLP_TRY {
1.245 - uninitialized_copy(__first, __last, this->_M_finish);
1.246 + _STLP_PRIV __ucopy(__first, __last, this->_M_finish);
1.247 }
1.248 - _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1,__new_finish._M_node + 1));
1.249 + _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1,
1.250 + __new_finish._M_node + 1))
1.251 this->_M_finish = __new_finish;
1.252 }
1.253 else
1.254 - _M_insert_aux(__pos, __first, __last, __n);
1.255 + _M_insert_range_aux(__pos, __first, __last, __n, _Movable());
1.256 }
1.257
1.258 #endif /* _STLP_MEMBER_TEMPLATES */
1.259
1.260 template <class _Tp, class _Alloc >
1.261 -__iterator__
1.262 -__deque__<_Tp,_Alloc>::erase(iterator __first, iterator __last)
1.263 -{
1.264 - if (__first == this->_M_start && __last == this->_M_finish) {
1.265 - clear();
1.266 - return this->_M_finish;
1.267 +__iterator__ deque<_Tp,_Alloc>::_M_erase(iterator __pos,
1.268 + const __true_type& /*_Movable*/) {
1.269 + difference_type __index = __pos - this->_M_start;
1.270 + if (size_type(__index) < this->size() >> 1) {
1.271 + //We move the start of the deque one position to the right
1.272 + //starting from the rightmost element to move.
1.273 + iterator __src = __pos, __dst = __pos;
1.274 + _STLP_STD::_Destroy(&(*__dst));
1.275 + if (__src != this->_M_start) {
1.276 + for (--__src; __dst != this->_M_start; --__src, --__dst) {
1.277 + _STLP_STD::_Move_Construct(&(*__dst), *__src);
1.278 + _STLP_STD::_Destroy_Moved(&(*__src));
1.279 + }
1.280 + }
1.281 + _M_pop_front_aux();
1.282 }
1.283 else {
1.284 - difference_type __n = __last - __first;
1.285 - difference_type __elems_before = __first - this->_M_start;
1.286 - if (__elems_before < difference_type(this->size() - __n) / 2) {
1.287 - copy_backward(this->_M_start, __first, __last);
1.288 - iterator __new_start = this->_M_start + __n;
1.289 - _STLP_STD::_Destroy(this->_M_start, __new_start);
1.290 - this->_M_destroy_nodes(this->_M_start._M_node, __new_start._M_node);
1.291 - this->_M_start = __new_start;
1.292 + iterator __src = __pos, __dst = __pos;
1.293 + _STLP_STD::_Destroy(&(*__dst));
1.294 + for (++__src; __src != this->_M_finish; ++__src, ++__dst) {
1.295 + _STLP_STD::_Move_Construct(&(*__dst), *__src);
1.296 + _STLP_STD::_Destroy_Moved(&(*__src));
1.297 + }
1.298 + //Duplication of the pop_back code without the destroy which has already been done:
1.299 + if (this->_M_finish._M_cur != this->_M_finish._M_first) {
1.300 + --this->_M_finish._M_cur;
1.301 }
1.302 else {
1.303 - copy(__last, this->_M_finish, __first);
1.304 - iterator __new_finish = this->_M_finish - __n;
1.305 - _STLP_STD::_Destroy(__new_finish, this->_M_finish);
1.306 - this->_M_destroy_nodes(__new_finish._M_node + 1, this->_M_finish._M_node + 1);
1.307 - this->_M_finish = __new_finish;
1.308 + _M_pop_back_aux();
1.309 }
1.310 - return this->_M_start + __elems_before;
1.311 }
1.312 + return this->_M_start + __index;
1.313 }
1.314
1.315 template <class _Tp, class _Alloc >
1.316 -void __deque__<_Tp,_Alloc>::clear()
1.317 -{
1.318 +__iterator__ deque<_Tp,_Alloc>::_M_erase(iterator __pos,
1.319 + const __false_type& /*_Movable*/) {
1.320 + iterator __next = __pos;
1.321 + ++__next;
1.322 + difference_type __index = __pos - this->_M_start;
1.323 + if (size_type(__index) < this->size() >> 1) {
1.324 + copy_backward(this->_M_start, __pos, __next);
1.325 + pop_front();
1.326 + }
1.327 + else {
1.328 + copy(__next, this->_M_finish, __pos);
1.329 + pop_back();
1.330 + }
1.331 + return this->_M_start + __index;
1.332 +}
1.333 +
1.334 +template <class _Tp, class _Alloc >
1.335 +__iterator__ deque<_Tp,_Alloc>::_M_erase(iterator __first, iterator __last,
1.336 + const __true_type& /*_Movable*/) {
1.337 + difference_type __n = __last - __first;
1.338 + difference_type __elems_before = __first - this->_M_start;
1.339 + if (__elems_before <= difference_type(this->size() - __n) / 2) {
1.340 + iterator __src = __first, __dst = __last;
1.341 + if (__src != this->_M_start) {
1.342 + for (--__src, --__dst; (__src >= this->_M_start) && (__dst >= __first); --__src, --__dst) {
1.343 + _STLP_STD::_Destroy(&(*__dst));
1.344 + _STLP_STD::_Move_Construct(&(*__dst), *__src);
1.345 + }
1.346 + if (__dst >= __first) {
1.347 + //There are more elements to erase than elements to move
1.348 + _STLP_STD::_Destroy_Range(__first, ++__dst);
1.349 + _STLP_STD::_Destroy_Moved_Range(this->_M_start, __first);
1.350 + }
1.351 + else {
1.352 + //There are more elements to move than elements to erase
1.353 + for (; __src >= this->_M_start; --__src, --__dst) {
1.354 + _STLP_STD::_Destroy_Moved(&(*__dst));
1.355 + _STLP_STD::_Move_Construct(&(*__dst), *__src);
1.356 + }
1.357 + _STLP_STD::_Destroy_Moved_Range(this->_M_start, ++__dst);
1.358 + }
1.359 + }
1.360 + else {
1.361 + _STLP_STD::_Destroy_Range(this->_M_start, __last);
1.362 + }
1.363 + iterator __new_start = this->_M_start + __n;
1.364 + this->_M_destroy_nodes(this->_M_start._M_node, __new_start._M_node);
1.365 + this->_M_start = __new_start;
1.366 + }
1.367 + else {
1.368 + if (__last != this->_M_finish) {
1.369 + iterator __src = __last, __dst = __first;
1.370 + for (; (__src != this->_M_finish) && (__dst != __last); ++__src, ++__dst) {
1.371 + _STLP_STD::_Destroy(&(*__dst));
1.372 + _STLP_STD::_Move_Construct(&(*__dst), *__src);
1.373 + }
1.374 + if (__dst != __last) {
1.375 + //There are more elements to erase than elements to move
1.376 + _STLP_STD::_Destroy_Range(__dst, __last);
1.377 + _STLP_STD::_Destroy_Moved_Range(__last, this->_M_finish);
1.378 + }
1.379 + else {
1.380 + //There are more elements to move than elements to erase
1.381 + for (; __src != this->_M_finish; ++__src, ++__dst) {
1.382 + _STLP_STD::_Destroy_Moved(&(*__dst));
1.383 + _STLP_STD::_Move_Construct(&(*__dst), *__src);
1.384 + }
1.385 + _STLP_STD::_Destroy_Moved_Range(__dst, this->_M_finish);
1.386 + }
1.387 + }
1.388 + else {
1.389 + _STLP_STD::_Destroy_Range(__first, this->_M_finish);
1.390 + }
1.391 + iterator __new_finish = this->_M_finish - __n;
1.392 + this->_M_destroy_nodes(__new_finish._M_node + 1, this->_M_finish._M_node + 1);
1.393 + this->_M_finish = __new_finish;
1.394 + }
1.395 + return this->_M_start + __elems_before;
1.396 +}
1.397 +
1.398 +template <class _Tp, class _Alloc >
1.399 +__iterator__ deque<_Tp,_Alloc>::_M_erase(iterator __first, iterator __last,
1.400 + const __false_type& /*_Movable*/) {
1.401 + difference_type __n = __last - __first;
1.402 + difference_type __elems_before = __first - this->_M_start;
1.403 + if (__elems_before <= difference_type(this->size() - __n) / 2) {
1.404 + copy_backward(this->_M_start, __first, __last);
1.405 + iterator __new_start = this->_M_start + __n;
1.406 + _STLP_STD::_Destroy_Range(this->_M_start, __new_start);
1.407 + this->_M_destroy_nodes(this->_M_start._M_node, __new_start._M_node);
1.408 + this->_M_start = __new_start;
1.409 + }
1.410 + else {
1.411 + copy(__last, this->_M_finish, __first);
1.412 + iterator __new_finish = this->_M_finish - __n;
1.413 + _STLP_STD::_Destroy_Range(__new_finish, this->_M_finish);
1.414 + this->_M_destroy_nodes(__new_finish._M_node + 1, this->_M_finish._M_node + 1);
1.415 + this->_M_finish = __new_finish;
1.416 + }
1.417 + return this->_M_start + __elems_before;
1.418 +}
1.419 +
1.420 +template <class _Tp, class _Alloc >
1.421 +void deque<_Tp,_Alloc>::clear() {
1.422 for (_Map_pointer __node = this->_M_start._M_node + 1;
1.423 __node < this->_M_finish._M_node;
1.424 ++__node) {
1.425 - _STLP_STD::_Destroy(*__node, *__node + this->buffer_size());
1.426 + _STLP_STD::_Destroy_Range(*__node, *__node + this->buffer_size());
1.427 this->_M_map_size.deallocate(*__node, this->buffer_size());
1.428 }
1.429
1.430 if (this->_M_start._M_node != this->_M_finish._M_node) {
1.431 - _STLP_STD::_Destroy(this->_M_start._M_cur, this->_M_start._M_last);
1.432 - _STLP_STD::_Destroy(this->_M_finish._M_first, this->_M_finish._M_cur);
1.433 + _STLP_STD::_Destroy_Range(this->_M_start._M_cur, this->_M_start._M_last);
1.434 + _STLP_STD::_Destroy_Range(this->_M_finish._M_first, this->_M_finish._M_cur);
1.435 this->_M_map_size.deallocate(this->_M_finish._M_first, this->buffer_size());
1.436 }
1.437 else
1.438 - _STLP_STD::_Destroy(this->_M_start._M_cur, this->_M_finish._M_cur);
1.439 + _STLP_STD::_Destroy_Range(this->_M_start._M_cur, this->_M_finish._M_cur);
1.440
1.441 this->_M_finish = this->_M_start;
1.442 }
1.443 @@ -256,375 +356,398 @@
1.444 // Precondition: this->_M_start and this->_M_finish have already been initialized,
1.445 // but none of the deque's elements have yet been constructed.
1.446 template <class _Tp, class _Alloc >
1.447 -void
1.448 -__deque__<_Tp,_Alloc>::_M_fill_initialize(const value_type& __val) {
1.449 - _STLP_LEAVE_VOLATILE _Map_pointer __cur = 0;
1.450 +void deque<_Tp,_Alloc>::_M_fill_initialize(const value_type& __val,
1.451 + const __false_type& /*_TrivialInit*/) {
1.452 + _Map_pointer __cur = this->_M_start._M_node;
1.453 _STLP_TRY {
1.454 - for (__cur = this->_M_start._M_node; __cur < this->_M_finish._M_node; ++__cur)
1.455 + for (; __cur < this->_M_finish._M_node; ++__cur)
1.456 uninitialized_fill(*__cur, *__cur + this->buffer_size(), __val);
1.457 uninitialized_fill(this->_M_finish._M_first, this->_M_finish._M_cur, __val);
1.458 }
1.459 - _STLP_UNWIND(_STLP_STD::_Destroy(this->_M_start, iterator(*__cur, __cur)));
1.460 + _STLP_UNWIND(_STLP_STD::_Destroy_Range(this->_M_start, iterator(*__cur, __cur)))
1.461 }
1.462
1.463
1.464 // Called only if this->_M_finish._M_cur == this->_M_finish._M_last - 1.
1.465 template <class _Tp, class _Alloc >
1.466 -void
1.467 -__deque__<_Tp,_Alloc>::_M_push_back_aux_v(const value_type& __t)
1.468 -{
1.469 - value_type __t_copy = __t;
1.470 - _STLP_PUSH_CLEANUP_ITEM(value_type, &__t_copy);
1.471 +void deque<_Tp,_Alloc>::_M_push_back_aux_v(const value_type& __t) {
1.472 _M_reserve_map_at_back();
1.473 *(this->_M_finish._M_node + 1) = this->_M_map_size.allocate(this->buffer_size());
1.474 _STLP_TRY {
1.475 - _Construct(this->_M_finish._M_cur, __t_copy);
1.476 + _Copy_Construct(this->_M_finish._M_cur, __t);
1.477 this->_M_finish._M_set_node(this->_M_finish._M_node + 1);
1.478 this->_M_finish._M_cur = this->_M_finish._M_first;
1.479 }
1.480 - _STLP_UNWIND(this->_M_map_size.deallocate(*(this->_M_finish._M_node + 1),
1.481 - this->buffer_size()));
1.482 -#ifdef _STLP_USE_TRAP_LEAVE
1.483 - CleanupStack::Pop();
1.484 -#endif
1.485 + _STLP_UNWIND(this->_M_map_size.deallocate(*(this->_M_finish._M_node + 1),
1.486 + this->buffer_size()))
1.487 }
1.488
1.489 -# ifndef _STLP_NO_ANACHRONISMS
1.490 +#if defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
1.491 // Called only if this->_M_finish._M_cur == this->_M_finish._M_last - 1.
1.492 template <class _Tp, class _Alloc >
1.493 -void
1.494 -__deque__<_Tp,_Alloc>::_M_push_back_aux()
1.495 -{
1.496 +void deque<_Tp,_Alloc>::_M_push_back_aux() {
1.497 _M_reserve_map_at_back();
1.498 *(this->_M_finish._M_node + 1) = this->_M_map_size.allocate(this->buffer_size());
1.499 _STLP_TRY {
1.500 - _Construct(this->_M_finish._M_cur);
1.501 + _STLP_STD::_Construct(this->_M_finish._M_cur);
1.502 this->_M_finish._M_set_node(this->_M_finish._M_node + 1);
1.503 this->_M_finish._M_cur = this->_M_finish._M_first;
1.504 }
1.505 - _STLP_UNWIND(this->_M_map_size.deallocate(*(this->_M_finish._M_node + 1),
1.506 - this->buffer_size()));
1.507 + _STLP_UNWIND(this->_M_map_size.deallocate(*(this->_M_finish._M_node + 1),
1.508 + this->buffer_size()))
1.509 }
1.510 -# endif
1.511 +#endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
1.512
1.513 // Called only if this->_M_start._M_cur == this->_M_start._M_first.
1.514 template <class _Tp, class _Alloc >
1.515 -void
1.516 -__deque__<_Tp,_Alloc>::_M_push_front_aux_v(const value_type& __t)
1.517 -{
1.518 - value_type __t_copy = __t;
1.519 - _STLP_PUSH_CLEANUP_ITEM(value_type, &__t_copy);
1.520 +void deque<_Tp,_Alloc>::_M_push_front_aux_v(const value_type& __t) {
1.521 _M_reserve_map_at_front();
1.522 *(this->_M_start._M_node - 1) = this->_M_map_size.allocate(this->buffer_size());
1.523 _STLP_TRY {
1.524 this->_M_start._M_set_node(this->_M_start._M_node - 1);
1.525 this->_M_start._M_cur = this->_M_start._M_last - 1;
1.526 - _Construct(this->_M_start._M_cur, __t_copy);
1.527 + _Copy_Construct(this->_M_start._M_cur, __t);
1.528 }
1.529 - _STLP_UNWIND((++this->_M_start,
1.530 - this->_M_map_size.deallocate(*(this->_M_start._M_node - 1), this->buffer_size())));
1.531 -#ifdef _STLP_USE_TRAP_LEAVE
1.532 - CleanupStack::Pop();
1.533 -#endif
1.534 -}
1.535 + _STLP_UNWIND((++this->_M_start,
1.536 + this->_M_map_size.deallocate(*(this->_M_start._M_node - 1), this->buffer_size())))
1.537 +}
1.538
1.539
1.540 -# ifndef _STLP_NO_ANACHRONISMS
1.541 +#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
1.542 // Called only if this->_M_start._M_cur == this->_M_start._M_first.
1.543 template <class _Tp, class _Alloc >
1.544 -void
1.545 -__deque__<_Tp,_Alloc>::_M_push_front_aux()
1.546 -{
1.547 +void deque<_Tp,_Alloc>::_M_push_front_aux() {
1.548 _M_reserve_map_at_front();
1.549 *(this->_M_start._M_node - 1) = this->_M_map_size.allocate(this->buffer_size());
1.550 _STLP_TRY {
1.551 this->_M_start._M_set_node(this->_M_start._M_node - 1);
1.552 this->_M_start._M_cur = this->_M_start._M_last - 1;
1.553 - _Construct(this->_M_start._M_cur);
1.554 + _STLP_STD::_Construct(this->_M_start._M_cur);
1.555 }
1.556 - _STLP_UNWIND((++this->_M_start, this->_M_map_size.deallocate(*(this->_M_start._M_node - 1),
1.557 - this->buffer_size() )));
1.558 -}
1.559 -# endif
1.560 + _STLP_UNWIND((++this->_M_start, this->_M_map_size.deallocate(*(this->_M_start._M_node - 1),
1.561 + this->buffer_size())))
1.562 +}
1.563 +#endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
1.564
1.565 // Called only if this->_M_finish._M_cur == this->_M_finish._M_first.
1.566 template <class _Tp, class _Alloc >
1.567 -void
1.568 -__deque__<_Tp,_Alloc>::_M_pop_back_aux()
1.569 -{
1.570 +void deque<_Tp,_Alloc>::_M_pop_back_aux() {
1.571 this->_M_map_size.deallocate(this->_M_finish._M_first, this->buffer_size());
1.572 this->_M_finish._M_set_node(this->_M_finish._M_node - 1);
1.573 this->_M_finish._M_cur = this->_M_finish._M_last - 1;
1.574 - _STLP_STD::_Destroy(this->_M_finish._M_cur);
1.575 }
1.576
1.577 -// Called only if this->_M_start._M_cur == this->_M_start._M_last - 1. Note that
1.578 -// if the deque has at least one element (a precondition for this member
1.579 -// function), and if this->_M_start._M_cur == this->_M_start._M_last, then the deque
1.580 +// Note that if the deque has at least one element (a precondition for this member
1.581 +// function), and if this->_M_start._M_cur == this->_M_start._M_last, then the deque
1.582 // must have at least two nodes.
1.583 template <class _Tp, class _Alloc >
1.584 -void
1.585 -__deque__<_Tp,_Alloc>::_M_pop_front_aux()
1.586 -{
1.587 - _STLP_STD::_Destroy(this->_M_start._M_cur);
1.588 - this->_M_map_size.deallocate(this->_M_start._M_first, this->buffer_size());
1.589 - this->_M_start._M_set_node(this->_M_start._M_node + 1);
1.590 - this->_M_start._M_cur = this->_M_start._M_first;
1.591 -}
1.592 -
1.593 -
1.594 +void deque<_Tp,_Alloc>::_M_pop_front_aux() {
1.595 + if (this->_M_start._M_cur != this->_M_start._M_last - 1)
1.596 + ++this->_M_start._M_cur;
1.597 + else {
1.598 + this->_M_map_size.deallocate(this->_M_start._M_first, this->buffer_size());
1.599 + this->_M_start._M_set_node(this->_M_start._M_node + 1);
1.600 + this->_M_start._M_cur = this->_M_start._M_first;
1.601 + }
1.602 +}
1.603
1.604 template <class _Tp, class _Alloc >
1.605 -__iterator__
1.606 -__deque__<_Tp,_Alloc>::_M_insert_aux_prepare(iterator __pos) {
1.607 - difference_type __index = __pos - this->_M_start;
1.608 - if (__index < difference_type(size() / 2)) {
1.609 - push_front(front());
1.610 - iterator __front1 = this->_M_start;
1.611 - ++__front1;
1.612 - iterator __front2 = __front1;
1.613 - ++__front2;
1.614 - __pos = this->_M_start + __index;
1.615 - iterator __pos1 = __pos;
1.616 - ++__pos1;
1.617 - copy(__front2, __pos1, __front1);
1.618 +__iterator__ deque<_Tp,_Alloc>::_M_fill_insert_aux(iterator __pos, size_type __n,
1.619 + const value_type& __x,
1.620 + const __true_type& /*_Movable*/) {
1.621 + const difference_type __elems_before = __pos - this->_M_start;
1.622 + size_type __length = this->size();
1.623 + value_type __x_copy = __x;
1.624 + if (__elems_before <= difference_type(__length / 2)) {
1.625 + iterator __new_start = _M_reserve_elements_at_front(__n);
1.626 + __pos = this->_M_start + __elems_before;
1.627 + _STLP_TRY {
1.628 + iterator __dst = __new_start;
1.629 + iterator __src = this->_M_start;
1.630 + for (; __src != __pos; ++__dst, ++__src) {
1.631 + _STLP_STD::_Move_Construct(&(*__dst), *__src);
1.632 + _STLP_STD::_Destroy_Moved(&(*__src));
1.633 + }
1.634 + this->_M_start = __new_start;
1.635 + uninitialized_fill(__dst, __src, __x_copy);
1.636 + __pos = __dst;
1.637 + }
1.638 + _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
1.639 }
1.640 else {
1.641 - push_back(back());
1.642 - iterator __back1 = this->_M_finish;
1.643 - --__back1;
1.644 - iterator __back2 = __back1;
1.645 - --__back2;
1.646 - __pos = this->_M_start + __index;
1.647 - copy_backward(__pos, __back2, __back1);
1.648 + iterator __new_finish = _M_reserve_elements_at_back(__n);
1.649 + const difference_type __elems_after = difference_type(__length) - __elems_before;
1.650 + __pos = this->_M_finish - __elems_after;
1.651 + _STLP_TRY {
1.652 + iterator __dst = __new_finish;
1.653 + iterator __src = this->_M_finish;
1.654 + for (--__src, --__dst; __src >= __pos; --__src, --__dst) {
1.655 + _STLP_STD::_Move_Construct(&(*__dst), *__src);
1.656 + _STLP_STD::_Destroy_Moved(&(*__src));
1.657 + }
1.658 + this->_M_finish = __new_finish;
1.659 + uninitialized_fill(__pos, __pos + __n, __x_copy);
1.660 + }
1.661 + _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1))
1.662 }
1.663 return __pos;
1.664 }
1.665
1.666 template <class _Tp, class _Alloc >
1.667 -__iterator__
1.668 -__deque__<_Tp,_Alloc>::_M_insert_aux(iterator __pos,
1.669 - const value_type& __x) {
1.670 +__iterator__ deque<_Tp,_Alloc>::_M_fill_insert_aux(iterator __pos, size_type __n,
1.671 + const value_type& __x,
1.672 + const __false_type& /*_Movable*/) {
1.673 + const difference_type __elems_before = __pos - this->_M_start;
1.674 + size_type __length = this->size();
1.675 value_type __x_copy = __x;
1.676 - _STLP_PUSH_CLEANUP_ITEM(value_type, &__x_copy);
1.677 - _STLP_MPWFIX_TRY //*TY 06/01/2000 - mpw forget to call dtor on __x_copy without this try block
1.678 - __pos = _M_insert_aux_prepare(__pos);
1.679 - *__pos = __x_copy;
1.680 -#ifdef _STLP_USE_TRAP_LEAVE
1.681 - CleanupStack::Pop();
1.682 -#endif
1.683 + if (__elems_before <= difference_type(__length / 2)) {
1.684 + iterator __new_start = _M_reserve_elements_at_front(__n);
1.685 + iterator __old_start = this->_M_start;
1.686 + __pos = this->_M_start + __elems_before;
1.687 + _STLP_TRY {
1.688 + if (__elems_before >= difference_type(__n)) {
1.689 + iterator __start_n = this->_M_start + difference_type(__n);
1.690 + _STLP_PRIV __ucopy(this->_M_start, __start_n, __new_start);
1.691 + this->_M_start = __new_start;
1.692 + copy(__start_n, __pos, __old_start);
1.693 + fill(__pos - difference_type(__n), __pos, __x_copy);
1.694 + __pos -= difference_type(__n);
1.695 + }
1.696 + else {
1.697 + _STLP_PRIV __uninitialized_copy_fill(this->_M_start, __pos, __new_start,
1.698 + this->_M_start, __x_copy);
1.699 + this->_M_start = __new_start;
1.700 + fill(__old_start, __pos, __x_copy);
1.701 + }
1.702 + }
1.703 + _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
1.704 + }
1.705 + else {
1.706 + iterator __new_finish = _M_reserve_elements_at_back(__n);
1.707 + iterator __old_finish = this->_M_finish;
1.708 + const difference_type __elems_after =
1.709 + difference_type(__length) - __elems_before;
1.710 + __pos = this->_M_finish - __elems_after;
1.711 + _STLP_TRY {
1.712 + if (__elems_after > difference_type(__n)) {
1.713 + iterator __finish_n = this->_M_finish - difference_type(__n);
1.714 + _STLP_PRIV __ucopy(__finish_n, this->_M_finish, this->_M_finish);
1.715 + this->_M_finish = __new_finish;
1.716 + copy_backward(__pos, __finish_n, __old_finish);
1.717 + fill(__pos, __pos + difference_type(__n), __x_copy);
1.718 + }
1.719 + else {
1.720 + _STLP_PRIV __uninitialized_fill_copy(this->_M_finish, __pos + difference_type(__n),
1.721 + __x_copy, __pos, this->_M_finish);
1.722 + this->_M_finish = __new_finish;
1.723 + fill(__pos, __old_finish, __x_copy);
1.724 + }
1.725 + }
1.726 + _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1))
1.727 + }
1.728 return __pos;
1.729 - _STLP_MPWFIX_CATCH //*TY 06/01/2000 -
1.730 +}
1.731 +
1.732 +#if !defined (_STLP_MEMBER_TEMPLATES)
1.733 +template <class _Tp, class _Alloc >
1.734 +void deque<_Tp,_Alloc>::_M_insert_range_aux(iterator __pos,
1.735 + const value_type* __first, const value_type* __last,
1.736 + size_type __n, const __true_type& /*_Movable*/) {
1.737 + const difference_type __elems_before = __pos - this->_M_start;
1.738 + size_type __length = size();
1.739 + if (__elems_before <= difference_type(__length / 2)) {
1.740 + iterator __new_start = _M_reserve_elements_at_front(__n);
1.741 + __pos = this->_M_start + __elems_before;
1.742 + _STLP_TRY {
1.743 + iterator __dst = __new_start;
1.744 + iterator __src = this->_M_start;
1.745 + for (; __src != __pos; ++__dst, ++__src) {
1.746 + _STLP_STD::_Move_Construct(&(*__dst), *__src);
1.747 + _STLP_STD::_Destroy_Moved(&(*__src));
1.748 + }
1.749 + this->_M_start = __new_start;
1.750 + _STLP_PRIV __ucopy(__first, __last, __dst);
1.751 + }
1.752 + _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
1.753 + }
1.754 + else {
1.755 + iterator __new_finish = _M_reserve_elements_at_back(__n);
1.756 + const difference_type __elems_after = difference_type(__length) - __elems_before;
1.757 + __pos = this->_M_finish - __elems_after;
1.758 + _STLP_TRY {
1.759 + iterator __dst = __new_finish;
1.760 + iterator __src = this->_M_finish;
1.761 + for (--__src, --__dst; __src >= __pos; --__src, --__dst) {
1.762 + _STLP_STD::_Move_Construct(&(*__dst), *__src);
1.763 + _STLP_STD::_Destroy_Moved(&(*__src));
1.764 + }
1.765 + this->_M_finish = __new_finish;
1.766 + _STLP_PRIV __ucopy(__first, __last, __pos);
1.767 + }
1.768 + _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1))
1.769 + }
1.770 }
1.771
1.772 template <class _Tp, class _Alloc >
1.773 -__iterator__
1.774 -__deque__<_Tp,_Alloc>::_M_insert_aux(iterator __pos)
1.775 -{
1.776 - __pos = _M_insert_aux_prepare(__pos);
1.777 - *__pos = value_type();
1.778 - return __pos;
1.779 +void deque<_Tp,_Alloc>::_M_insert_range_aux(iterator __pos,
1.780 + const value_type* __first, const value_type* __last,
1.781 + size_type __n, const __false_type& /*_Movable*/) {
1.782 + const difference_type __elems_before = __pos - this->_M_start;
1.783 + size_type __length = size();
1.784 + if (__elems_before <= difference_type(__length / 2)) {
1.785 + iterator __new_start = _M_reserve_elements_at_front(__n);
1.786 + iterator __old_start = this->_M_start;
1.787 + __pos = this->_M_start + __elems_before;
1.788 + _STLP_TRY {
1.789 + if (__elems_before >= difference_type(__n)) {
1.790 + iterator __start_n = this->_M_start + difference_type(__n);
1.791 + _STLP_PRIV __ucopy(this->_M_start, __start_n, __new_start);
1.792 + this->_M_start = __new_start;
1.793 + copy(__start_n, __pos, __old_start);
1.794 + copy(__first, __last, __pos - difference_type(__n));
1.795 + }
1.796 + else {
1.797 + const value_type* __mid = __first + (difference_type(__n) - __elems_before);
1.798 + __uninitialized_copy_copy(this->_M_start, __pos, __first, __mid, __new_start);
1.799 + this->_M_start = __new_start;
1.800 + copy(__mid, __last, __old_start);
1.801 + }
1.802 + }
1.803 + _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
1.804 + }
1.805 + else {
1.806 + iterator __new_finish = _M_reserve_elements_at_back(__n);
1.807 + iterator __old_finish = this->_M_finish;
1.808 + const difference_type __elems_after =
1.809 + difference_type(__length) - __elems_before;
1.810 + __pos = this->_M_finish - __elems_after;
1.811 + _STLP_TRY {
1.812 +
1.813 + if (__elems_after > difference_type(__n)) {
1.814 + iterator __finish_n = this->_M_finish - difference_type(__n);
1.815 + _STLP_PRIV __ucopy(__finish_n, this->_M_finish, this->_M_finish);
1.816 + this->_M_finish = __new_finish;
1.817 + copy_backward(__pos, __finish_n, __old_finish);
1.818 + copy(__first, __last, __pos);
1.819 + }
1.820 + else {
1.821 + const value_type* __mid = __first + __elems_after;
1.822 + __uninitialized_copy_copy(__mid, __last, __pos, this->_M_finish, this->_M_finish);
1.823 + this->_M_finish = __new_finish;
1.824 + copy(__first, __mid, __pos);
1.825 + }
1.826 + }
1.827 + _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1))
1.828 + }
1.829 }
1.830
1.831 template <class _Tp, class _Alloc >
1.832 -void
1.833 -__deque__<_Tp,_Alloc>::_M_insert_aux(iterator __pos,
1.834 - size_type __n,
1.835 - const value_type& __x)
1.836 -{
1.837 +void deque<_Tp,_Alloc>::_M_insert_range_aux(iterator __pos,
1.838 + const_iterator __first, const_iterator __last,
1.839 + size_type __n, const __true_type& /*_Movable*/) {
1.840 const difference_type __elems_before = __pos - this->_M_start;
1.841 - size_type __length = this->size();
1.842 - value_type __x_copy = __x;
1.843 - _STLP_PUSH_CLEANUP_ITEM(value_type, &__x_copy);
1.844 + size_type __length = size();
1.845 + if (__elems_before <= difference_type(__length / 2)) {
1.846 + iterator __new_start = _M_reserve_elements_at_front(__n);
1.847 + __pos = this->_M_start + __elems_before;
1.848 + _STLP_TRY {
1.849 + iterator __dst = __new_start;
1.850 + iterator __src = this->_M_start;
1.851 + for (; __src != __pos; ++__dst, ++__src) {
1.852 + _STLP_STD::_Move_Construct(&(*__dst), *__src);
1.853 + _STLP_STD::_Destroy_Moved(&(*__src));
1.854 + }
1.855 + this->_M_start = __new_start;
1.856 + _STLP_PRIV __ucopy(__first, __last, __dst);
1.857 + }
1.858 + _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
1.859 + }
1.860 + else {
1.861 + iterator __new_finish = _M_reserve_elements_at_back(__n);
1.862 + const difference_type __elems_after = difference_type(__length) - __elems_before;
1.863 + __pos = this->_M_finish - __elems_after;
1.864 + _STLP_TRY {
1.865 + iterator __dst = __new_finish;
1.866 + iterator __src = this->_M_finish;
1.867 + for (--__src, --__dst; __src >= __pos; --__src, --__dst) {
1.868 + _STLP_STD::_Move_Construct(&(*__dst), *__src);
1.869 + _STLP_STD::_Destroy_Moved(&(*__src));
1.870 + }
1.871 + this->_M_finish = __new_finish;
1.872 + _STLP_PRIV __ucopy(__first, __last, __pos);
1.873 + }
1.874 + _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1))
1.875 + }
1.876 +}
1.877
1.878 +template <class _Tp, class _Alloc >
1.879 +void deque<_Tp,_Alloc>::_M_insert_range_aux(iterator __pos,
1.880 + const_iterator __first, const_iterator __last,
1.881 + size_type __n, const __false_type& /*_Movable*/) {
1.882 + const difference_type __elems_before = __pos - this->_M_start;
1.883 + size_type __length = size();
1.884 if (__elems_before < difference_type(__length / 2)) {
1.885 iterator __new_start = _M_reserve_elements_at_front(__n);
1.886 iterator __old_start = this->_M_start;
1.887 __pos = this->_M_start + __elems_before;
1.888 _STLP_TRY {
1.889 if (__elems_before >= difference_type(__n)) {
1.890 - iterator __start_n = this->_M_start + difference_type(__n);
1.891 - uninitialized_copy(this->_M_start, __start_n, __new_start);
1.892 - this->_M_start = __new_start;
1.893 - copy(__start_n, __pos, __old_start);
1.894 - fill(__pos - difference_type(__n), __pos, __x_copy);
1.895 - }
1.896 - else {
1.897 - __uninitialized_copy_fill(this->_M_start, __pos, __new_start,
1.898 - this->_M_start, __x_copy);
1.899 - this->_M_start = __new_start;
1.900 - fill(__old_start, __pos, __x_copy);
1.901 - }
1.902 - }
1.903 - _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node));
1.904 - }
1.905 - else {
1.906 - iterator __new_finish = _M_reserve_elements_at_back(__n);
1.907 - iterator __old_finish = this->_M_finish;
1.908 - const difference_type __elems_after =
1.909 - difference_type(__length) - __elems_before;
1.910 - __pos = this->_M_finish - __elems_after;
1.911 - _STLP_TRY {
1.912 - if (__elems_after > difference_type(__n)) {
1.913 - iterator __finish_n = this->_M_finish - difference_type(__n);
1.914 - uninitialized_copy(__finish_n, this->_M_finish, this->_M_finish);
1.915 - this->_M_finish = __new_finish;
1.916 - copy_backward(__pos, __finish_n, __old_finish);
1.917 - fill(__pos, __pos + difference_type(__n), __x_copy);
1.918 - }
1.919 - else {
1.920 - __uninitialized_fill_copy(this->_M_finish, __pos + difference_type(__n),
1.921 - __x_copy, __pos, this->_M_finish);
1.922 - this->_M_finish = __new_finish;
1.923 - fill(__pos, __old_finish, __x_copy);
1.924 - }
1.925 - }
1.926 - _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1));
1.927 - }
1.928 -#ifdef _STLP_USE_TRAP_LEAVE
1.929 - CleanupStack::Pop();
1.930 -#endif
1.931 -}
1.932 -
1.933 -#ifndef _STLP_MEMBER_TEMPLATES
1.934 -template <class _Tp, class _Alloc >
1.935 -void
1.936 -__deque__<_Tp,_Alloc>::_M_insert_aux(iterator __pos,
1.937 - const value_type* __first,
1.938 - const value_type* __last,
1.939 - size_type __n)
1.940 -{
1.941 -
1.942 - const difference_type __elemsbefore = __pos - this->_M_start;
1.943 - size_type __length = size();
1.944 - if (__elemsbefore < difference_type(__length / 2)) {
1.945 - iterator __new_start = _M_reserve_elements_at_front(__n);
1.946 - iterator __old_start = this->_M_start;
1.947 - __pos = this->_M_start + __elemsbefore;
1.948 - _STLP_TRY {
1.949 - if (__elemsbefore >= difference_type(__n)) {
1.950 - iterator __start_n = this->_M_start + difference_type(__n);
1.951 - uninitialized_copy(this->_M_start, __start_n, __new_start);
1.952 + iterator __start_n = this->_M_start + __n;
1.953 + _STLP_PRIV __ucopy(this->_M_start, __start_n, __new_start);
1.954 this->_M_start = __new_start;
1.955 copy(__start_n, __pos, __old_start);
1.956 copy(__first, __last, __pos - difference_type(__n));
1.957 }
1.958 else {
1.959 - const value_type* __mid =
1.960 - __first + (difference_type(__n) - __elemsbefore);
1.961 - __uninitialized_copy_copy(this->_M_start, __pos, __first, __mid,
1.962 - __new_start, _IsPODType());
1.963 + const_iterator __mid = __first + (__n - __elems_before);
1.964 + __uninitialized_copy_copy(this->_M_start, __pos, __first, __mid, __new_start);
1.965 this->_M_start = __new_start;
1.966 copy(__mid, __last, __old_start);
1.967 }
1.968 }
1.969 - _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node));
1.970 + _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
1.971 }
1.972 else {
1.973 iterator __new_finish = _M_reserve_elements_at_back(__n);
1.974 iterator __old_finish = this->_M_finish;
1.975 - const difference_type __elemsafter =
1.976 - difference_type(__length) - __elemsbefore;
1.977 - __pos = this->_M_finish - __elemsafter;
1.978 + const difference_type __elems_after = __length - __elems_before;
1.979 + __pos = this->_M_finish - __elems_after;
1.980 _STLP_TRY {
1.981 - if (__elemsafter > difference_type(__n)) {
1.982 + if (__elems_after > difference_type(__n)) {
1.983 iterator __finish_n = this->_M_finish - difference_type(__n);
1.984 - uninitialized_copy(__finish_n, this->_M_finish, this->_M_finish);
1.985 + _STLP_PRIV __ucopy(__finish_n, this->_M_finish, this->_M_finish);
1.986 this->_M_finish = __new_finish;
1.987 copy_backward(__pos, __finish_n, __old_finish);
1.988 copy(__first, __last, __pos);
1.989 }
1.990 else {
1.991 - const value_type* __mid = __first + __elemsafter;
1.992 - __uninitialized_copy_copy(__mid, __last, __pos, this->_M_finish, this->_M_finish, _IsPODType());
1.993 + const_iterator __mid = __first + __elems_after;
1.994 + __uninitialized_copy_copy(__mid, __last, __pos, this->_M_finish, this->_M_finish);
1.995 this->_M_finish = __new_finish;
1.996 copy(__first, __mid, __pos);
1.997 }
1.998 }
1.999 - _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1));
1.1000 + _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1))
1.1001 }
1.1002 }
1.1003 -
1.1004 -template <class _Tp, class _Alloc >
1.1005 -void
1.1006 -__deque__<_Tp,_Alloc>::_M_insert_aux(iterator __pos,
1.1007 - const_iterator __first,
1.1008 - const_iterator __last,
1.1009 - size_type __n)
1.1010 -{
1.1011 - const difference_type __elemsbefore = __pos - this->_M_start;
1.1012 - size_type __length = size();
1.1013 - if (__elemsbefore < difference_type(__length / 2)) {
1.1014 - iterator __new_start = _M_reserve_elements_at_front(__n);
1.1015 - iterator __old_start = this->_M_start;
1.1016 - __pos = this->_M_start + __elemsbefore;
1.1017 - _STLP_TRY {
1.1018 - if (__elemsbefore >= difference_type(__n)) {
1.1019 - iterator __start_n = this->_M_start + __n;
1.1020 - uninitialized_copy(this->_M_start, __start_n, __new_start);
1.1021 - this->_M_start = __new_start;
1.1022 - copy(__start_n, __pos, __old_start);
1.1023 - copy(__first, __last, __pos - difference_type(__n));
1.1024 - }
1.1025 - else {
1.1026 - const_iterator __mid = __first + (__n - __elemsbefore);
1.1027 - __uninitialized_copy_copy(this->_M_start, __pos, __first, __mid,
1.1028 - __new_start, _IsPODType());
1.1029 - this->_M_start = __new_start;
1.1030 - copy(__mid, __last, __old_start);
1.1031 - }
1.1032 - }
1.1033 - _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node));
1.1034 - }
1.1035 - else {
1.1036 - iterator __new_finish = _M_reserve_elements_at_back(__n);
1.1037 - iterator __old_finish = this->_M_finish;
1.1038 - const difference_type __elemsafter = __length - __elemsbefore;
1.1039 - __pos = this->_M_finish - __elemsafter;
1.1040 - _STLP_TRY {
1.1041 - if (__elemsafter > difference_type(__n)) {
1.1042 - iterator __finish_n = this->_M_finish - difference_type(__n);
1.1043 - uninitialized_copy(__finish_n, this->_M_finish, this->_M_finish);
1.1044 - this->_M_finish = __new_finish;
1.1045 - copy_backward(__pos, __finish_n, __old_finish);
1.1046 - copy(__first, __last, __pos);
1.1047 - }
1.1048 - else {
1.1049 - const_iterator __mid = __first + __elemsafter;
1.1050 - __uninitialized_copy_copy(__mid, __last, __pos, this->_M_finish, this->_M_finish, _IsPODType());
1.1051 - this->_M_finish = __new_finish;
1.1052 - copy(__first, __mid, __pos);
1.1053 - }
1.1054 - }
1.1055 - _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1));
1.1056 - }
1.1057 -}
1.1058 -
1.1059 #endif /* _STLP_MEMBER_TEMPLATES */
1.1060
1.1061 template <class _Tp, class _Alloc >
1.1062 -void
1.1063 -__deque__<_Tp,_Alloc>::_M_new_elements_at_front(size_type __new_elems)
1.1064 -{
1.1065 +void deque<_Tp,_Alloc>::_M_new_elements_at_front(size_type __new_elems) {
1.1066 size_type __new_nodes
1.1067 = (__new_elems + this->buffer_size() - 1) / this->buffer_size();
1.1068 _M_reserve_map_at_front(__new_nodes);
1.1069 - size_type __i =1;
1.1070 + size_type __i = 1;
1.1071 _STLP_TRY {
1.1072 for (; __i <= __new_nodes; ++__i)
1.1073 *(this->_M_start._M_node - __i) = this->_M_map_size.allocate(this->buffer_size());
1.1074 }
1.1075 - _STLP_CATCH_ALL {
1.1076 - for (size_type __j = 1; __j < __i; ++__j)
1.1077 - this->_M_map_size.deallocate(*(this->_M_start._M_node - __j), this->buffer_size());
1.1078 - _STLP_RETHROW;
1.1079 - }
1.1080 + _STLP_UNWIND(for (size_type __j = 1; __j < __i; ++__j)
1.1081 + this->_M_map_size.deallocate(*(this->_M_start._M_node - __j), this->buffer_size()))
1.1082 }
1.1083
1.1084 template <class _Tp, class _Alloc >
1.1085 -void
1.1086 -__deque__<_Tp,_Alloc>::_M_new_elements_at_back(size_type __new_elems)
1.1087 -{
1.1088 +void deque<_Tp,_Alloc>::_M_new_elements_at_back(size_type __new_elems) {
1.1089 size_type __new_nodes
1.1090 = (__new_elems + this->buffer_size() - 1) / this->buffer_size();
1.1091 _M_reserve_map_at_back(__new_nodes);
1.1092 @@ -633,33 +756,28 @@
1.1093 for (; __i <= __new_nodes; ++__i)
1.1094 *(this->_M_finish._M_node + __i) = this->_M_map_size.allocate(this->buffer_size());
1.1095 }
1.1096 - _STLP_CATCH_ALL {
1.1097 - for (size_type __j = 1; __j < __i; ++__j)
1.1098 - this->_M_map_size.deallocate(*(this->_M_finish._M_node + __j), this->buffer_size());
1.1099 - _STLP_RETHROW;
1.1100 - }
1.1101 + _STLP_UNWIND(for (size_type __j = 1; __j < __i; ++__j)
1.1102 + this->_M_map_size.deallocate(*(this->_M_finish._M_node + __j), this->buffer_size()))
1.1103 }
1.1104
1.1105 template <class _Tp, class _Alloc >
1.1106 -void
1.1107 -__deque__<_Tp,_Alloc>::_M_reallocate_map(size_type __nodes_to_add,
1.1108 - bool __add_at_front)
1.1109 -{
1.1110 +void deque<_Tp,_Alloc>::_M_reallocate_map(size_type __nodes_to_add,
1.1111 + bool __add_at_front) {
1.1112 size_type __old_num_nodes = this->_M_finish._M_node - this->_M_start._M_node + 1;
1.1113 size_type __new_num_nodes = __old_num_nodes + __nodes_to_add;
1.1114
1.1115 _Map_pointer __new_nstart;
1.1116 if (this->_M_map_size._M_data > 2 * __new_num_nodes) {
1.1117 - __new_nstart = this->_M_map._M_data + (this->_M_map_size._M_data - __new_num_nodes) / 2
1.1118 + __new_nstart = this->_M_map._M_data + (this->_M_map_size._M_data - __new_num_nodes) / 2
1.1119 + (__add_at_front ? __nodes_to_add : 0);
1.1120 if (__new_nstart < this->_M_start._M_node)
1.1121 copy(this->_M_start._M_node, this->_M_finish._M_node + 1, __new_nstart);
1.1122 else
1.1123 - copy_backward(this->_M_start._M_node, this->_M_finish._M_node + 1,
1.1124 + copy_backward(this->_M_start._M_node, this->_M_finish._M_node + 1,
1.1125 __new_nstart + __old_num_nodes);
1.1126 }
1.1127 else {
1.1128 - size_type __new_map_size =
1.1129 + size_type __new_map_size =
1.1130 this->_M_map_size._M_data + (max)((size_t)this->_M_map_size._M_data, __nodes_to_add) + 2;
1.1131
1.1132 _Map_pointer __new_map = this->_M_map.allocate(__new_map_size);
1.1133 @@ -676,13 +794,18 @@
1.1134 this->_M_finish._M_set_node(__new_nstart + __old_num_nodes - 1);
1.1135 }
1.1136
1.1137 +#if defined (deque)
1.1138 +# undef deque
1.1139 +_STLP_MOVE_TO_STD_NAMESPACE
1.1140 +#endif
1.1141 +
1.1142 _STLP_END_NAMESPACE
1.1143
1.1144 -# undef __iterator__
1.1145 -# undef iterator
1.1146 -# undef const_iterator
1.1147 -# undef size_type
1.1148 -# undef value_type
1.1149 +#undef __iterator__
1.1150 +#undef iterator
1.1151 +#undef const_iterator
1.1152 +#undef size_type
1.1153 +#undef value_type
1.1154
1.1155 #endif /* _STLP_DEQUE_C */
1.1156