ReactOS 0.4.15-dev-7788-g1ad9096
_vector.h
Go to the documentation of this file.
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_VECTOR_H
31#define _STLP_INTERNAL_VECTOR_H
32
33#ifndef _STLP_INTERNAL_ALGOBASE_H
34# include <stl/_algobase.h>
35#endif
36
37#ifndef _STLP_INTERNAL_ALLOC_H
38# include <stl/_alloc.h>
39#endif
40
41#ifndef _STLP_INTERNAL_ITERATOR_H
42# include <stl/_iterator.h>
43#endif
44
45#ifndef _STLP_INTERNAL_UNINITIALIZED_H
46# include <stl/_uninitialized.h>
47#endif
48
50
51// The vector base class serves one purpose, its constructor and
52// destructor allocate (but don't initialize) storage. This makes
53// exception safety easier.
54
56
57template <class _Tp, class _Alloc>
59public:
63 typedef _Tp* pointer;
65
67 : _M_start(0), _M_finish(0), _M_end_of_storage(__a, 0) {}
68
69 _Vector_base(size_t __n, const _Alloc& __a)
70 : _M_start(0), _M_finish(0), _M_end_of_storage(__a, 0) {
75 }
76
77#if !defined (_STLP_NO_MOVE_SEMANTIC)
81 //Set the source as empty:
82 src.get()._M_finish = src.get()._M_end_of_storage._M_data = src.get()._M_start = 0;
83 }
84#endif
85
89 }
90
91protected:
94
98};
99
100#if defined (_STLP_USE_PTR_SPECIALIZATIONS)
101# define vector _STLP_PTR_IMPL_NAME(vector)
102#elif defined (_STLP_DEBUG)
103# define vector _STLP_NON_DBG_NAME(vector)
104#else
106#endif
107
108template <class _Tp, _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Tp>) >
109class vector : protected _STLP_PRIV _Vector_base<_Tp, _Alloc>
110#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (vector)
111 , public __stlport_class<vector<_Tp, _Alloc> >
112#endif
113{
114private:
117public:
120
121 typedef _Tp value_type;
126
129 typedef size_t size_type;
132
134
136 { return _STLP_CONVERT_ALLOCATOR((const allocator_type&)this->_M_end_of_storage, _Tp); }
137
138private:
139#if defined (_STLP_NO_MOVE_SEMANTIC)
140 typedef __false_type _Movable;
141#endif
142
143 // handles insertions on overflow
144 void _M_insert_overflow_aux(pointer __pos, const _Tp& __x, const __false_type& /*_Movable*/,
145 size_type __fill_len, bool __atend);
146 void _M_insert_overflow_aux(pointer __pos, const _Tp& __x, const __true_type& /*_Movable*/,
147 size_type __fill_len, bool __atend) {
148 //We need to take care of self referencing here:
149 if (_M_is_inside(__x)) {
150 value_type __x_copy = __x;
151 _M_insert_overflow_aux(__pos, __x_copy, __false_type(), __fill_len, __atend);
152 return;
153 }
154 _M_insert_overflow_aux(__pos, __x, __false_type(), __fill_len, __atend);
155 }
156
157 void _M_insert_overflow(pointer __pos, const _Tp& __x, const __false_type& /*_TrivialCopy*/,
158 size_type __fill_len, bool __atend = false) {
159#if !defined (_STLP_NO_MOVE_SEMANTIC)
160 typedef typename __move_traits<_Tp>::implemented _Movable;
161#endif
162 _M_insert_overflow_aux(__pos, __x, _Movable(), __fill_len, __atend);
163 }
164 void _M_insert_overflow(pointer __pos, const _Tp& __x, const __true_type& /*_TrivialCopy*/,
165 size_type __fill_len, bool __atend = false);
167 if (__n >= size_type(this->_M_finish - this->_M_start))
168 this->_M_throw_out_of_range();
169 }
170
172 const size_type __size = size();
173 if (__n > max_size() - __size)
174 this->_M_throw_length_error();
175 size_type __len = __size + (max)(__n, __size);
176 if (__len > max_size() || __len < __size)
177 __len = max_size(); // overflow
178 return __len;
179 }
180
181public:
182 iterator begin() { return this->_M_start; }
183 const_iterator begin() const { return this->_M_start; }
184 iterator end() { return this->_M_finish; }
185 const_iterator end() const { return this->_M_finish; }
186
188 const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
190 const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
191
192 size_type size() const { return size_type(this->_M_finish - this->_M_start); }
194 size_type __vector_max_size = size_type(-1) / sizeof(_Tp);
195 typename allocator_type::size_type __alloc_max_size = this->_M_end_of_storage.max_size();
196 return (__alloc_max_size < __vector_max_size)?__alloc_max_size:__vector_max_size;
197 }
198
199 size_type capacity() const { return size_type(this->_M_end_of_storage._M_data - this->_M_start); }
200 bool empty() const { return this->_M_start == this->_M_finish; }
201
204
205 reference front() { return *begin(); }
206 const_reference front() const { return *begin(); }
207 reference back() { return *(end() - 1); }
208 const_reference back() const { return *(end() - 1); }
209
211 const_reference at(size_type __n) const { _M_range_check(__n); return (*this)[__n]; }
212
213 _Tp* data() { return this->_M_start; }
214 const _Tp* data() const { return this->_M_start; }
215
216#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
217 explicit vector(const allocator_type& __a = allocator_type())
218#else
219 vector()
221 vector(const allocator_type& __a)
222#endif
224
225#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
226private:
227 //We always call _M_initialize with only 1 parameter. Default parameter
228 //is used to allow explicit instanciation of vector with types with no
229 //default constructor.
231 { this->_M_finish = _STLP_PRIV __uninitialized_init(this->_M_start, __n, __val); }
232public:
235 { _M_initialize(__n); }
237#else
238 explicit vector(size_type __n)
240 { this->_M_finish = _STLP_PRIV __uninitialized_init(this->_M_start, __n, _STLP_DEFAULT_CONSTRUCTED(_Tp)); }
241 vector(size_type __n, const _Tp& __val)
243 { this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_start, __n, __val); }
244 vector(size_type __n, const _Tp& __val, const allocator_type& __a)
245#endif
247 { this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_start, __n, __val); }
248
249 vector(const _Self& __x)
250 : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__x.size(), __x.get_allocator()) {
252 this->_M_finish = _STLP_PRIV __ucopy_ptrs(__x.begin(), __x.end(), this->_M_start, _TrivialUCopy());
253 }
254
255#if !defined (_STLP_NO_MOVE_SEMANTIC)
258 {}
259#endif
260
261#if defined (_STLP_MEMBER_TEMPLATES)
262private:
263 template <class _Integer>
264 void _M_initialize_aux(_Integer __n, _Integer __val,
265 const __true_type& /*_IsIntegral*/) {
266 size_type __real_n = __n;
267 this->_M_start = this->_M_end_of_storage.allocate(__n, __real_n);
268 this->_M_end_of_storage._M_data = this->_M_start + __real_n;
269 this->_M_finish = _STLP_PRIV __uninitialized_fill_n(this->_M_start, __n, __val);
270 }
271
272 template <class _InputIterator>
273 void _M_initialize_aux(_InputIterator __first, _InputIterator __last,
274 const __false_type& /*_IsIntegral*/)
275 { _M_range_initialize(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator)); }
276
277public:
278 // Check whether it's an integral type. If so, it's not an iterator.
279 template <class _InputIterator>
280 vector(_InputIterator __first, _InputIterator __last,
282 : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__a) {
283 typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
284 _M_initialize_aux(__first, __last, _Integral());
285 }
286
287# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
288 template <class _InputIterator>
289 vector(_InputIterator __first, _InputIterator __last)
291 typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
292 _M_initialize_aux(__first, __last, _Integral());
293 }
294# endif /* _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS */
295
296#else /* _STLP_MEMBER_TEMPLATES */
297 vector(const _Tp* __first, const _Tp* __last,
298 const allocator_type& __a = allocator_type())
299 : _STLP_PRIV _Vector_base<_Tp, _Alloc>(__last - __first, __a) {
301 this->_M_finish = _STLP_PRIV __ucopy_ptrs(__first, __last, this->_M_start, _TrivialUCopy());
302 }
303#endif /* _STLP_MEMBER_TEMPLATES */
304
305 //As the vector container is a back insert oriented container it
306 //seems rather logical to destroy elements in reverse order.
307 ~vector() { _STLP_STD::_Destroy_Range(rbegin(), rend()); }
308
309 _Self& operator=(const _Self& __x);
310
311 void reserve(size_type __n);
312
313 // assign(), a generalized assignment member function. Two
314 // versions: one that takes a count, and one that takes a range.
315 // The range version is a member template, so we dispatch on whether
316 // or not the type is an integer.
317
319 void _M_fill_assign(size_type __n, const _Tp& __val);
320
321#if defined (_STLP_MEMBER_TEMPLATES)
322 template <class _ForwardIter>
323 void _M_assign_aux(_ForwardIter __first, _ForwardIter __last, const forward_iterator_tag &) {
324#else
326 typedef const_iterator _ForwardIter;
327#endif
328 const size_type __len = _STLP_STD::distance(__first, __last);
329 if (__len > capacity()) {
330 size_type __n = __len;
331 iterator __tmp = _M_allocate_and_copy(__n, __first, __last);
332 _M_clear();
333 _M_set(__tmp, __tmp + __len, __tmp + __n);
334 }
335 else if (size() >= __len) {
336 iterator __new_finish = copy(__first, __last, this->_M_start);
337 _STLP_STD::_Destroy_Range(__new_finish, this->_M_finish);
338 this->_M_finish = __new_finish;
339 }
340 else {
341 _ForwardIter __mid = __first;
342 _STLP_STD::advance(__mid, size());
343 _STLP_STD::copy(__first, __mid, this->_M_start);
344 this->_M_finish = _STLP_STD::uninitialized_copy(__mid, __last, this->_M_finish);
345 }
346 }
347
348#if defined (_STLP_MEMBER_TEMPLATES)
349 template <class _InputIter>
350 void _M_assign_aux(_InputIter __first, _InputIter __last,
351 const input_iterator_tag &) {
352 iterator __cur = begin();
353 for ( ; __first != __last && __cur != end(); ++__cur, ++__first)
354 *__cur = *__first;
355 if (__first == __last)
356 erase(__cur, end());
357 else
358 insert(end(), __first, __last);
359 }
360
361 template <class _Integer>
362 void _M_assign_dispatch(_Integer __n, _Integer __val,
363 const __true_type& /*_IsIntegral*/)
365
366 template <class _InputIter>
367 void _M_assign_dispatch(_InputIter __first, _InputIter __last,
368 const __false_type& /*_IsIntegral*/)
369 { _M_assign_aux(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIter)); }
370
371 template <class _InputIterator>
372 void assign(_InputIterator __first, _InputIterator __last) {
373 typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
374 _M_assign_dispatch(__first, __last, _Integral());
375 }
376#endif
377
378#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
379 void push_back(const _Tp& __x = _STLP_DEFAULT_CONSTRUCTED(_Tp)) {
380#else
381 void push_back(const _Tp& __x) {
382#endif
383 if (this->_M_finish != this->_M_end_of_storage._M_data) {
384 _Copy_Construct(this->_M_finish, __x);
385 ++this->_M_finish;
386 }
387 else {
389 _M_insert_overflow(this->_M_finish, __x, _TrivialCopy(), 1, true);
390 }
391 }
392
393#if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
394 iterator insert(iterator __pos, const _Tp& __x = _STLP_DEFAULT_CONSTRUCTED(_Tp));
395#else
396 iterator insert(iterator __pos, const _Tp& __x);
397#endif
398
399#if defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
401 iterator insert(iterator __pos) { return insert(__pos, _STLP_DEFAULT_CONSTRUCTED(_Tp)); }
402#endif
403
404 void swap(_Self& __x) {
405 _STLP_STD::swap(this->_M_start, __x._M_start);
406 _STLP_STD::swap(this->_M_finish, __x._M_finish);
407 this->_M_end_of_storage.swap(__x._M_end_of_storage);
408 }
409#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
410 void _M_swap_workaround(_Self& __x) { swap(__x); }
411#endif
412
413private:
414 void _M_fill_insert_aux (iterator __pos, size_type __n, const _Tp& __x, const __true_type& /*_Movable*/);
415 void _M_fill_insert_aux (iterator __pos, size_type __n, const _Tp& __x, const __false_type& /*_Movable*/);
416 void _M_fill_insert (iterator __pos, size_type __n, const _Tp& __x);
417
418 bool _M_is_inside(const value_type& __x) const {
419 return (&__x >= this->_M_start && &__x < this->_M_finish);
420 }
421
422#if defined (_STLP_MEMBER_TEMPLATES)
423 template <class _ForwardIterator>
425 _ForwardIterator __first, _ForwardIterator __last,
426#else
429#endif
430 size_type __n) {
432#if !defined (_STLP_NO_MOVE_SEMANTIC)
433 typedef typename __move_traits<_Tp>::implemented _Movable;
434#endif
436 pointer __new_start = this->_M_end_of_storage.allocate(__len, __len);
437 pointer __new_finish = __new_start;
438 _STLP_TRY {
439 __new_finish = _STLP_PRIV __uninitialized_move(this->_M_start, __pos, __new_start, _TrivialUCopy(), _Movable());
440 __new_finish = uninitialized_copy(__first, __last, __new_finish);
441 __new_finish = _STLP_PRIV __uninitialized_move(__pos, this->_M_finish, __new_finish, _TrivialUCopy(), _Movable());
442 }
443 _STLP_UNWIND((_STLP_STD::_Destroy_Range(__new_start,__new_finish),
444 this->_M_end_of_storage.deallocate(__new_start,__len)))
446 _M_set(__new_start, __new_finish, __new_start + __len);
447 }
448
449#if defined (_STLP_MEMBER_TEMPLATES)
450 template <class _ForwardIterator>
451 void _M_range_insert_aux(iterator __pos,
452 _ForwardIterator __first, _ForwardIterator __last,
453#else
456#endif
457 size_type __n, const __true_type& /*_Movable*/) {
458 iterator __src = this->_M_finish - 1;
459 iterator __dst = __src + __n;
460 for (; __src >= __pos; --__dst, --__src) {
461 _STLP_STD::_Move_Construct(__dst, *__src);
462 _STLP_STD::_Destroy_Moved(__src);
463 }
464 uninitialized_copy(__first, __last, __pos);
465 this->_M_finish += __n;
466 }
467
468#if defined (_STLP_MEMBER_TEMPLATES)
469 template <class _ForwardIterator>
470 void _M_range_insert_aux(iterator __pos,
471 _ForwardIterator __first, _ForwardIterator __last,
472#else
475#endif
476 size_type __n, const __false_type& /*_Movable*/) {
479 const size_type __elems_after = this->_M_finish - __pos;
480 pointer __old_finish = this->_M_finish;
481 if (__elems_after > __n) {
482 _STLP_PRIV __ucopy_ptrs(this->_M_finish - __n, this->_M_finish, this->_M_finish, _TrivialUCopy());
483 this->_M_finish += __n;
484 _STLP_PRIV __copy_backward_ptrs(__pos, __old_finish - __n, __old_finish, _TrivialCopy());
485 copy(__first, __last, __pos);
486 }
487 else {
488#if defined ( _STLP_MEMBER_TEMPLATES )
489 _ForwardIterator __mid = __first;
490 _STLP_STD::advance(__mid, __elems_after);
491#else
492 const_pointer __mid = __first + __elems_after;
493#endif
494 uninitialized_copy(__mid, __last, this->_M_finish);
495 this->_M_finish += __n - __elems_after;
496 _STLP_PRIV __ucopy_ptrs(__pos, __old_finish, this->_M_finish, _TrivialUCopy());
497 this->_M_finish += __elems_after;
498 copy(__first, __mid, __pos);
499 } /* elems_after */
500 }
501
502
503#if defined (_STLP_MEMBER_TEMPLATES)
504 template <class _Integer>
505 void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
506 const __true_type&)
507 { _M_fill_insert(__pos, (size_type) __n, (_Tp) __val); }
508
509 template <class _InputIterator>
510 void _M_insert_dispatch(iterator __pos,
511 _InputIterator __first, _InputIterator __last,
512 const __false_type&)
513 { _M_range_insert(__pos, __first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator)); }
514
515public:
516 // Check whether it's an integral type. If so, it's not an iterator.
517 template <class _InputIterator>
518 void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {
519 typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
520 _M_insert_dispatch(__pos, __first, __last, _Integral());
521 }
522
523private:
524 template <class _InputIterator>
525 void _M_range_insert(iterator __pos,
526 _InputIterator __first, _InputIterator __last,
527 const input_iterator_tag &) {
528 for ( ; __first != __last; ++__first) {
529 __pos = insert(__pos, *__first);
530 ++__pos;
531 }
532 }
533
534 template <class _ForwardIterator>
535 void _M_range_insert(iterator __pos,
536 _ForwardIterator __first, _ForwardIterator __last,
537 const forward_iterator_tag &) {
538#else
539public:
540 void insert(iterator __pos,
542#endif
543#if !defined (_STLP_NO_MOVE_SEMANTIC)
544 typedef typename __move_traits<_Tp>::implemented _Movable;
545#endif
546 /* This method do not check self referencing.
547 * Standard forbids it, checked by the debug mode.
548 */
549 if (__first != __last) {
550 size_type __n = _STLP_STD::distance(__first, __last);
551
552 if (size_type(this->_M_end_of_storage._M_data - this->_M_finish) >= __n) {
553 _M_range_insert_aux(__pos, __first, __last, __n, _Movable());
554 }
555 else {
556 _M_range_insert_realloc(__pos, __first, __last, __n);
557 }
558 }
559 }
560
561public:
562 void insert (iterator __pos, size_type __n, const _Tp& __x)
563 { _M_fill_insert(__pos, __n, __x); }
564
565 void pop_back() {
566 --this->_M_finish;
567 _STLP_STD::_Destroy(this->_M_finish);
568 }
569
570private:
571 iterator _M_erase(iterator __pos, const __true_type& /*_Movable*/) {
572 _STLP_STD::_Destroy(__pos);
573 iterator __dst = __pos, __src = __dst + 1;
574 iterator __end = end();
575 for (; __src != __end; ++__dst, ++__src) {
576 _STLP_STD::_Move_Construct(__dst, *__src);
577 _STLP_STD::_Destroy_Moved(__src);
578 }
579 this->_M_finish = __dst;
580 return __pos;
581 }
582 iterator _M_erase(iterator __pos, const __false_type& /*_Movable*/) {
583 if (__pos + 1 != end()) {
585 _STLP_PRIV __copy_ptrs(__pos + 1, this->_M_finish, __pos, _TrivialCopy());
586 }
587 --this->_M_finish;
588 _STLP_STD::_Destroy(this->_M_finish);
589 return __pos;
590 }
591 iterator _M_erase(iterator __first, iterator __last, const __true_type& /*_Movable*/) {
592 iterator __dst = __first, __src = __last;
593 iterator __end = end();
594 for (; __dst != __last && __src != __end; ++__dst, ++__src) {
595 _STLP_STD::_Destroy(__dst);
596 _STLP_STD::_Move_Construct(__dst, *__src);
597 }
598 if (__dst != __last) {
599 //There is more elements to erase than element to move:
600 _STLP_STD::_Destroy_Range(__dst, __last);
601 _STLP_STD::_Destroy_Moved_Range(__last, __end);
602 }
603 else {
604 //There is more element to move than element to erase:
605 for (; __src != __end; ++__dst, ++__src) {
606 _STLP_STD::_Destroy_Moved(__dst);
607 _STLP_STD::_Move_Construct(__dst, *__src);
608 }
609 _STLP_STD::_Destroy_Moved_Range(__dst, __end);
610 }
611 this->_M_finish = __dst;
612 return __first;
613 }
614 iterator _M_erase(iterator __first, iterator __last, const __false_type& /*_Movable*/) {
616 pointer __i = _STLP_PRIV __copy_ptrs(__last, this->_M_finish, __first, _TrivialCopy());
617 _STLP_STD::_Destroy_Range(__i, this->_M_finish);
618 this->_M_finish = __i;
619 return __first;
620 }
621
622public:
624#if !defined (_STLP_NO_MOVE_SEMANTIC)
625 typedef typename __move_traits<_Tp>::implemented _Movable;
626#endif
627 return _M_erase(__pos, _Movable());
628 }
630#if !defined (_STLP_NO_MOVE_SEMANTIC)
631 typedef typename __move_traits<_Tp>::implemented _Movable;
632#endif
633 if (__first == __last)
634 return __first;
635 return _M_erase(__first, __last, _Movable());
636 }
637
638#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
639 void resize(size_type __new_size, const _Tp& __x = _STLP_DEFAULT_CONSTRUCTED(_Tp)) {
640#else
641 void resize(size_type __new_size, const _Tp& __x) {
642#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
643 if (__new_size < size())
644 erase(begin() + __new_size, end());
645 else
646 insert(end(), __new_size - size(), __x);
647 }
648
649#if defined (_STLP_DONT_SUP_DFLT_PARAM)
650 void resize(size_type __new_size) { resize(__new_size, _STLP_DEFAULT_CONSTRUCTED(_Tp)); }
651#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
652
653 void clear() {
654 erase(begin(), end());
655 }
656
657private:
658 void _M_clear() {
659 _STLP_STD::_Destroy_Range(rbegin(), rend());
660 this->_M_end_of_storage.deallocate(this->_M_start, this->_M_end_of_storage._M_data - this->_M_start);
661 }
662
664 _STLP_STD::_Destroy_Moved_Range(rbegin(), rend());
665 this->_M_end_of_storage.deallocate(this->_M_start, this->_M_end_of_storage._M_data - this->_M_start);
666 }
667
668 void _M_set(pointer __s, pointer __f, pointer __e) {
669 this->_M_start = __s;
670 this->_M_finish = __f;
671 this->_M_end_of_storage._M_data = __e;
672 }
673
674#if defined (_STLP_MEMBER_TEMPLATES)
675 template <class _ForwardIterator>
677 _ForwardIterator __first, _ForwardIterator __last)
678#else /* _STLP_MEMBER_TEMPLATES */
681#endif /* _STLP_MEMBER_TEMPLATES */
682 {
683 pointer __result = this->_M_end_of_storage.allocate(__n, __n);
684 _STLP_TRY {
685 uninitialized_copy(__first, __last, __result);
686 return __result;
687 }
688 _STLP_UNWIND(this->_M_end_of_storage.deallocate(__result, __n))
689 _STLP_RET_AFTER_THROW(__result)
690 }
691
692
693#if defined (_STLP_MEMBER_TEMPLATES)
694 template <class _InputIterator>
695 void _M_range_initialize(_InputIterator __first, _InputIterator __last,
696 const input_iterator_tag &) {
697 for ( ; __first != __last; ++__first)
698 push_back(*__first);
699 }
700 // This function is only called by the constructor.
701 template <class _ForwardIterator>
702 void _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
703 const forward_iterator_tag &) {
704 size_type __n = _STLP_STD::distance(__first, __last);
705 this->_M_start = this->_M_end_of_storage.allocate(__n, __n);
706 this->_M_end_of_storage._M_data = this->_M_start + __n;
707 this->_M_finish = uninitialized_copy(__first, __last, this->_M_start);
708 }
709#endif /* _STLP_MEMBER_TEMPLATES */
710};
711
712#if defined (vector)
713# undef vector
715#endif
716
718
719#if !defined (_STLP_LINK_TIME_INSTANTIATION)
720# include <stl/_vector.c>
721#endif
722
723#if defined (_STLP_USE_PTR_SPECIALIZATIONS)
724# include <stl/pointers/_vector.h>
725#endif
726
727//We define the bool specialization before the debug interfave
728//to benefit of the debug version of vector even for the bool
729//specialization.
730#if !defined (_STLP_NO_BOOL) || !defined (_STLP_NO_EXTENSIONS)
731# if !defined (_STLP_INTERNAL_BVECTOR_H)
732# include <stl/_bvector.h>
733# endif
734#endif
735
736#if defined (_STLP_DEBUG)
737# include <stl/debug/_vector.h>
738#endif
739
741
742#if !defined (_STLP_NO_BOOL) && !defined (_STLP_NO_EXTENSIONS)
743// This typedef is non-standard. It is provided for backward compatibility.
745#endif
746
747#define _STLP_TEMPLATE_HEADER template <class _Tp, class _Alloc>
748#define _STLP_TEMPLATE_CONTAINER vector<_Tp, _Alloc>
749#include <stl/_relops_cont.h>
750#undef _STLP_TEMPLATE_CONTAINER
751#undef _STLP_TEMPLATE_HEADER
752
753#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
754# if !defined (_STLP_NO_MOVE_SEMANTIC)
755template <class _Tp, class _Alloc>
756struct __move_traits<vector<_Tp, _Alloc> > {
757 typedef __true_type implemented;
759};
760# endif
761
762# if !defined (_STLP_DEBUG)
763template <class _Tp, class _Alloc>
764struct _DefaultZeroValue<vector<_Tp, _Alloc> >
766# endif
767
768#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
769
771
772#endif /* _STLP_VECTOR_H */
773
774// Local Variables:
775// mode:C++
776// End:
#define reverse_iterator
Definition: _abbrevs.h:34
_STLP_INLINE_LOOP _InputIter __last
Definition: _algo.h:68
return __n
Definition: _algo.h:75
_STLP_MOVE_TO_PRIV_NAMESPACE _OutputIter __copy_backward_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, const __false_type &)
Definition: _algobase.h:299
_OutputIter __copy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, const __false_type &)
Definition: _algobase.h:260
_STLP_INLINE_LOOP _InputIter const _Tp & __val
Definition: _algobase.h:656
#define _STLP_CONVERT_ALLOCATOR(__a, _Tp)
Definition: _alloc.h:183
#define _STLP_FORCE_ALLOCATORS(a, y)
Definition: _alloc.h:436
#define _STLP_MPWFIX_CATCH
Definition: _apple.h:111
#define _STLP_MPWFIX_TRY
Definition: _apple.h:110
#define _Alloc
Definition: _bvector.h:330
void _Copy_Construct(_Tp *__p, const _Tp &__val)
Definition: _construct.h:130
#define _STLP_DEFAULT_CONSTRUCTED(_TTp)
Definition: _construct.h:265
#define _STLP_PRIV
Definition: _dm.h:70
#define _STLP_ITERATOR_CATEGORY(_It, _Tp)
_OutputIter __ucopy_ptrs(_InputIter __first, _InputIter __last, _OutputIter __result, const __false_type &)
_ForwardIter __uninitialized_init(_ForwardIter __first, _Size __n, const _Tp &__val)
_STLP_MOVE_TO_STD_NAMESPACE _ForwardIter uninitialized_copy(_InputIter __first, _InputIter __last, _ForwardIter __result)
_ForwardIter __uninitialized_move(_InputIter __first, _InputIter __last, _ForwardIter __result, _TrivialUCpy __trivial_ucpy, const __false_type &)
_ForwardIter __uninitialized_fill_n(_ForwardIter __first, _Size __n, const _Tp &__x)
_STLP_END_NAMESPACE _STLP_BEGIN_NAMESPACE typedef vector< bool, allocator< bool > > bit_vector
Definition: _vector.h:744
void get(int argc, const char *argv[])
Definition: cmds.c:480
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
_Value _M_data
Definition: _alloc.h:478
_Tp * allocate(size_type __n, size_type &__allocated_n)
Definition: _alloc.h:525
~_Vector_base()
Definition: _vector.h:86
void _STLP_FUNCTION_THROWS _M_throw_length_error() const
Definition: _vector.c:40
_Vector_base< _Tp, _Alloc > _Self
Definition: _vector.h:60
_AllocProxy _M_end_of_storage
Definition: _vector.h:97
pointer _M_finish
Definition: _vector.h:96
_Tp * pointer
Definition: _vector.h:63
_Vector_base(size_t __n, const _Alloc &__a)
Definition: _vector.h:69
void _STLP_FUNCTION_THROWS _M_throw_out_of_range() const
Definition: _vector.c:44
_Vector_base(__move_source< _Self > src)
Definition: _vector.h:78
_Alloc allocator_type
Definition: _vector.h:62
pointer _M_start
Definition: _vector.h:95
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
#define _STLP_UNWIND(action)
Definition: features.h:824
#define _STLP_RET_AFTER_THROW(data)
Definition: features.h:829
#define _STLP_FUNCTION_THROWS
Definition: features.h:872
#define _STLP_MOVE_TO_STD_NAMESPACE
Definition: features.h:525
#define _STLP_ALLOCATOR_TYPE_DFL
Definition: features.h:691
#define _STLP_TRY
Definition: features.h:817
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
#define _STLP_END_NAMESPACE
Definition: features.h:503
#define _STLP_MOVE_TO_PRIV_NAMESPACE
Definition: features.h:524
char typename[32]
Definition: main.c:84
GLsizeiptr size
Definition: glext.h:5919
GLenum src
Definition: glext.h:6340
GLsizei const GLvoid * pointer
Definition: glext.h:5848
static BOOL complete
Definition: htmldoc.c:198
#define swap(a, b)
Definition: qsort.c:63
iterator erase(iterator __pos)
Definition: _vector.h:623
void _M_fill_insert(iterator __pos, size_type __n, const _Tp &__x)
Definition: _vector.c:166
void pop_back()
Definition: _vector.h:565
iterator _M_erase(iterator __pos, const __true_type &)
Definition: _vector.h:571
void _M_insert_overflow_aux(pointer __pos, const _Tp &__x, const __false_type &, size_type __fill_len, bool __atend)
Definition: _vector.c:81
iterator end()
Definition: _vector.h:184
const_iterator begin() const
Definition: _vector.h:183
iterator _M_erase(iterator __pos, const __false_type &)
Definition: _vector.h:582
void reserve(size_type __n)
Definition: _vector.c:62
void _M_initialize(size_type __n, const _Tp &__val=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _vector.h:230
const_iterator end() const
Definition: _vector.h:185
void assign(const_iterator __first, const_iterator __last)
Definition: _vector.h:325
const value_type * const_pointer
Definition: _vector.h:123
void _M_set(pointer __s, pointer __f, pointer __e)
Definition: _vector.h:668
void insert(iterator __pos, const_iterator __first, const_iterator __last)
Definition: _vector.h:540
void _M_insert_overflow(pointer __pos, const _Tp &__x, const __false_type &, size_type __fill_len, bool __atend=false)
Definition: _vector.h:157
vector(const _Self &__x)
Definition: _vector.h:249
vector(size_type __n, const _Tp &__val, const allocator_type &__a=allocator_type())
Definition: _vector.h:236
reference back()
Definition: _vector.h:207
~vector()
Definition: _vector.h:307
reverse_iterator rbegin()
Definition: _vector.h:187
_Tp value_type
Definition: _vector.h:121
size_type max_size() const
Definition: _vector.h:193
void _M_range_insert_aux(iterator __pos, const_iterator __first, const_iterator __last, size_type __n, const __false_type &)
Definition: _vector.h:473
void _M_clear()
Definition: _vector.h:658
vector(__move_source< _Self > src)
Definition: _vector.h:256
void push_back(const _Tp &__x=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _vector.h:379
bool _M_is_inside(const value_type &__x) const
Definition: _vector.h:418
size_type capacity() const
Definition: _vector.h:199
void resize(size_type __new_size, const _Tp &__x=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _vector.h:639
value_type * pointer
Definition: _vector.h:122
_Self & operator=(const _Self &__x)
Definition: _vector.c:182
reference operator[](size_type __n)
Definition: _vector.h:202
size_type _M_compute_next_size(size_type __n)
Definition: _vector.h:171
reference front()
Definition: _vector.h:205
_Base::allocator_type allocator_type
Definition: _vector.h:119
vector(const allocator_type &__a=allocator_type())
Definition: _vector.h:217
iterator _M_erase(iterator __first, iterator __last, const __true_type &)
Definition: _vector.h:591
const_reverse_iterator rend() const
Definition: _vector.h:190
iterator begin()
Definition: _vector.h:182
void insert(iterator __pos, size_type __n, const _Tp &__x)
Definition: _vector.h:562
void swap(_Self &__x)
Definition: _vector.h:404
const_reference front() const
Definition: _vector.h:206
const value_type * const_iterator
Definition: _vector.h:125
size_type size() const
Definition: _vector.h:192
const_reverse_iterator rbegin() const
Definition: _vector.h:188
void _M_fill_insert_aux(iterator __pos, size_type __n, const _Tp &__x, const __true_type &)
Definition: _vector.c:122
size_t size_type
Definition: _vector.h:129
allocator_type get_allocator() const
Definition: _vector.h:135
void _M_range_insert_realloc(iterator __pos, const_iterator __first, const_iterator __last, size_type __n)
Definition: _vector.h:427
vector(size_type __n)
Definition: _vector.h:233
reference at(size_type __n)
Definition: _vector.h:210
reverse_iterator rend()
Definition: _vector.h:189
iterator _M_erase(iterator __first, iterator __last, const __false_type &)
Definition: _vector.h:614
vector< _Tp, _Alloc > _Self
Definition: _vector.h:116
const _Tp * data() const
Definition: _vector.h:214
ptrdiff_t difference_type
Definition: _vector.h:130
void _M_fill_assign(size_type __n, const _Tp &__val)
Definition: _vector.c:210
bool empty() const
Definition: _vector.h:200
value_type * iterator
Definition: _vector.h:124
value_type & reference
Definition: _vector.h:127
iterator erase(iterator __first, iterator __last)
Definition: _vector.h:629
void clear()
Definition: _vector.h:653
const_reference operator[](size_type __n) const
Definition: _vector.h:203
void assign(size_type __n, const _Tp &__val)
Definition: _vector.h:318
_Tp * data()
Definition: _vector.h:213
const value_type & const_reference
Definition: _vector.h:128
void _M_range_check(size_type __n) const
Definition: _vector.h:166
const_reference at(size_type __n) const
Definition: _vector.h:211
void _M_range_insert_aux(iterator __pos, const_iterator __first, const_iterator __last, size_type __n, const __true_type &)
Definition: _vector.h:454
_STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS
Definition: _vector.h:133
pointer _M_allocate_and_copy(size_type &__n, const_pointer __first, const_pointer __last)
Definition: _vector.h:679
_STLP_PRIV _Vector_base< _Tp, _Alloc > _Base
Definition: _vector.h:115
vector(const _Tp *__first, const _Tp *__last, const allocator_type &__a=allocator_type())
Definition: _vector.h:297
void _M_insert_overflow_aux(pointer __pos, const _Tp &__x, const __true_type &, size_type __fill_len, bool __atend)
Definition: _vector.h:146
const_reference back() const
Definition: _vector.h:208
void _M_clear_after_move()
Definition: _vector.h:663
#define max(a, b)
Definition: svc.c:63
static int insert
Definition: xmllint.c:138
#define const
Definition: zconf.h:233