Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
4 * Hewlett-Packard Company
6 * Copyright (c) 1996,1997
7 * Silicon Graphics Computer Systems, Inc.
10 * Moscow Center for SPARC Technology
15 * This material is provided "as is", with absolutely no warranty expressed
16 * or implied. Any use is at your own risk.
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.
26 /* NOTE: This is an internal header file, included by other STL headers.
27 * You should not attempt to use it directly.
30 #ifndef _STLP_INTERNAL_BVECTOR_H
31 #define _STLP_INTERNAL_BVECTOR_H
33 #ifndef _STLP_INTERNAL_VECTOR_H
34 # include <stl/_vector.h>
38 #define __WORD_BIT (int(CHAR_BIT*sizeof(unsigned int)))
43 struct _Bit_reference {
46 _Bit_reference(unsigned int* __x, unsigned int __y)
47 : _M_p(__x), _M_mask(__y) {}
50 _Bit_reference() : _M_p(0), _M_mask(0) {}
52 operator bool() const {
53 return !(!(*_M_p & _M_mask));
55 _Bit_reference& operator=(bool __x) {
56 if (__x) *_M_p |= _M_mask;
57 else *_M_p &= ~_M_mask;
60 _Bit_reference& operator=(const _Bit_reference& __x) {
61 return *this = bool(__x);
63 bool operator==(const _Bit_reference& __x) const {
64 return bool(*this) == bool(__x);
66 bool operator<(const _Bit_reference& __x) const {
67 return !bool(*this) && bool(__x);
70 _Bit_reference& operator |= (bool __x) {
75 _Bit_reference& operator &= (bool __x) {
80 void flip() { *_M_p ^= _M_mask; }
84 inline void swap(_Bit_reference& __x, _Bit_reference& __y)
86 bool __tmp = (bool)__x;
91 struct _Bit_iterator_base;
93 struct _Bit_iterator_base
95 typedef ptrdiff_t difference_type;
98 unsigned int _M_offset;
101 if (_M_offset++ == __WORD_BIT - 1) {
107 void _M_bump_down() {
108 if (_M_offset-- == 0) {
109 _M_offset = __WORD_BIT - 1;
114 _Bit_iterator_base() : _M_p(0), _M_offset(0) {}
115 _Bit_iterator_base(unsigned int* __x, unsigned int __y) : _M_p(__x), _M_offset(__y) {}
116 // _Bit_iterator_base( const _Bit_iterator_base& __x) : _M_p(__x._M_p), _M_offset(__x._M_offset) {}
117 // _Bit_iterator_base& operator = ( const _Bit_iterator_base& __x) { _M_p = __x._M_p ; _M_offset = __x._M_offset ; return *this; }
119 void _M_advance (difference_type __i) {
120 difference_type __n = __i + _M_offset;
121 _M_p += __n / __WORD_BIT;
122 __n = __n % __WORD_BIT;
124 _M_offset = (unsigned int) __n + __WORD_BIT;
127 _M_offset = (unsigned int) __n;
130 difference_type _M_subtract(const _Bit_iterator_base& __x) const {
131 return __WORD_BIT * (_M_p - __x._M_p) + _M_offset - __x._M_offset;
135 inline bool _STLP_CALL operator==(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) {
136 return __y._M_p == __x._M_p && __y._M_offset == __x._M_offset;
138 inline bool _STLP_CALL operator!=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) {
139 return __y._M_p != __x._M_p || __y._M_offset != __x._M_offset;
142 inline bool _STLP_CALL operator<(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) {
143 return __x._M_p < __y._M_p || (__x._M_p == __y._M_p && __x._M_offset < __y._M_offset);
146 inline bool _STLP_CALL operator>(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) {
147 return operator <(__y , __x);
149 inline bool _STLP_CALL operator<=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) {
152 inline bool _STLP_CALL operator>=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) {
156 template <class _Ref, class _Ptr>
157 struct _Bit_iter : public _Bit_iterator_base
159 typedef _Ref reference;
160 typedef _Ptr pointer;
161 typedef _Bit_iter<_Ref, _Ptr> _Self;
162 typedef random_access_iterator_tag iterator_category;
163 typedef bool value_type;
164 typedef ptrdiff_t difference_type;
165 typedef size_t size_type;
167 _Bit_iter(unsigned int* __x, unsigned int __y) : _Bit_iterator_base(__x, __y) {}
170 _Bit_iter(const _Bit_iter<_Bit_reference, _Bit_reference*>& __x):
171 _Bit_iterator_base((const _Bit_iterator_base&)__x) {}
173 // _Self& operator = (const _Bit_iter<_Bit_reference, _Bit_reference*>& __x)
174 // { (_Bit_iterator_base&)*this = (const _Bit_iterator_base&)__x; return *this; }
176 reference operator*() const {
177 return _Bit_reference(_M_p, 1UL << _M_offset);
179 _Self& operator++() {
183 _Self operator++(int) {
188 _Self& operator--() {
192 _Self operator--(int) {
197 _Self& operator+=(difference_type __i) {
201 _Self& operator-=(difference_type __i) {
205 _Self operator+(difference_type __i) const {
209 _Self operator-(difference_type __i) const {
213 difference_type operator-(const _Self& __x) const {
214 return _M_subtract(__x);
216 reference operator[](difference_type __i) { return *(*this + __i); }
219 template <class _Ref, class _Ptr>
220 inline _Bit_iter<_Ref,_Ptr> _STLP_CALL
221 operator+(ptrdiff_t __n, const _Bit_iter<_Ref, _Ptr>& __x) {
225 # ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
226 inline random_access_iterator_tag iterator_category(const _Bit_iterator_base&) {return random_access_iterator_tag();}
227 inline ptrdiff_t* distance_type(const _Bit_iterator_base&) {return (ptrdiff_t*)0;}
228 inline bool* value_type(const _Bit_iter<_Bit_reference, _Bit_reference*>&) {return (bool*)0;}
229 inline bool* value_type(const _Bit_iter<bool, const bool*>&) {return (bool*)0;}
232 typedef _Bit_iter<bool, const bool*> _Bit_const_iterator;
233 typedef _Bit_iter<_Bit_reference, _Bit_reference*> _Bit_iterator;
235 // Bit-vector base class, which encapsulates the difference between
236 // old SGI-style allocators and standard-conforming allocators.
239 template <class _Alloc>
243 _STLP_FORCE_ALLOCATORS(bool, _Alloc)
244 typedef typename _Alloc_traits<bool, _Alloc>::allocator_type allocator_type;
245 typedef unsigned int __chunk_type;
246 typedef typename _Alloc_traits<__chunk_type,
247 _Alloc>::allocator_type __chunk_allocator_type;
248 allocator_type get_allocator() const {
249 return _STLP_CONVERT_ALLOCATOR((const __chunk_allocator_type&)_M_end_of_storage, bool);
251 static allocator_type __get_dfl_allocator() { return allocator_type(); }
253 _Bvector_base(const allocator_type& __a)
254 : _M_start(), _M_finish(), _M_end_of_storage(_STLP_CONVERT_ALLOCATOR(__a, __chunk_type),
257 ~_Bvector_base() { _M_deallocate();
262 unsigned int* _M_bit_alloc(size_t __n)
263 { return _M_end_of_storage.allocate((__n + __WORD_BIT - 1)/__WORD_BIT); }
264 void _M_deallocate() {
266 _M_end_of_storage.deallocate(_M_start._M_p,
267 _M_end_of_storage._M_data - _M_start._M_p);
270 _Bit_iterator _M_start;
271 _Bit_iterator _M_finish;
272 _STLP_alloc_proxy<__chunk_type*, __chunk_type, __chunk_allocator_type> _M_end_of_storage;
276 // The next few lines are confusing. What we're doing is declaring a
277 // partial specialization of vector<T, Alloc> if we have the necessary
278 // compiler support. Otherwise, we define a class bit_vector which uses
279 // the default allocator.
281 #if defined(_STLP_CLASS_PARTIAL_SPECIALIZATION) && ! defined(_STLP_NO_BOOL) && ! defined (__SUNPRO_CC)
282 # define _STLP_VECBOOL_TEMPLATE
283 # define __BVEC_TMPL_HEADER template <class _Alloc>
285 # undef _STLP_VECBOOL_TEMPLATE
286 # ifdef _STLP_NO_BOOL
287 # define __BVEC_TMPL_HEADER
289 # define __BVEC_TMPL_HEADER _STLP_TEMPLATE_NULL
291 # if !(defined(__MRC__)||(defined(__SC__)&&!defined(__DMC__))) //*TY 12/17/2000 -
292 # define _Alloc _STLP_DEFAULT_ALLOCATOR(bool)
294 # define _Alloc allocator<bool>
299 # define __BVECTOR_QUALIFIED bit_vector
300 # define __BVECTOR bit_vector
302 # ifdef _STLP_VECBOOL_TEMPLATE
303 # define __BVECTOR_QUALIFIED __WORKAROUND_DBG_RENAME(vector) <bool, _Alloc>
305 # define __BVECTOR_QUALIFIED __WORKAROUND_DBG_RENAME(vector) <bool, allocator<bool> >
307 #if defined (_STLP_PARTIAL_SPEC_NEEDS_TEMPLATE_ARGS)
308 # define __BVECTOR __BVECTOR_QUALIFIED
310 # define __BVECTOR __WORKAROUND_DBG_RENAME(vector)
316 class __BVECTOR_QUALIFIED : public _Bvector_base<_Alloc >
318 typedef _Bvector_base<_Alloc > _Base;
319 typedef __BVECTOR_QUALIFIED _Self;
321 typedef bool value_type;
322 typedef size_t size_type;
323 typedef ptrdiff_t difference_type;
324 typedef _Bit_reference reference;
325 typedef bool const_reference;
326 typedef _Bit_reference* pointer;
327 typedef const bool* const_pointer;
328 typedef random_access_iterator_tag _Iterator_category;
330 typedef _Bit_iterator iterator;
331 typedef _Bit_const_iterator const_iterator;
333 #if defined ( _STLP_CLASS_PARTIAL_SPECIALIZATION )
334 typedef _STLP_STD::reverse_iterator<const_iterator> const_reverse_iterator;
335 typedef _STLP_STD::reverse_iterator<iterator> reverse_iterator;
336 #else /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
337 # if defined (_STLP_MSVC50_COMPATIBILITY)
338 typedef _STLP_STD::reverse_iterator<const_iterator, value_type, const_reference,
339 const_pointer, difference_type> const_reverse_iterator;
340 typedef _STLP_STD::reverse_iterator<iterator, value_type, reference, reference*,
341 difference_type> reverse_iterator;
343 typedef _STLP_STD::reverse_iterator<const_iterator, value_type, const_reference,
344 difference_type> const_reverse_iterator;
345 typedef _STLP_STD::reverse_iterator<iterator, value_type, reference, difference_type>
348 #endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
350 # ifdef _STLP_VECBOOL_TEMPLATE
351 typedef typename _Bvector_base<_Alloc >::allocator_type allocator_type;
352 typedef typename _Bvector_base<_Alloc >::__chunk_type __chunk_type ;
354 typedef _Bvector_base<_Alloc >::allocator_type allocator_type;
355 typedef _Bvector_base<_Alloc >::__chunk_type __chunk_type ;
360 void _M_initialize(size_type __n) {
361 unsigned int* __q = this->_M_bit_alloc(__n);
362 this->_M_end_of_storage._M_data = __q + (__n + __WORD_BIT - 1)/__WORD_BIT;
363 this->_M_start = iterator(__q, 0);
364 this->_M_finish = this->_M_start + difference_type(__n);
366 void _M_insert_aux(iterator __position, bool __x) {
367 if (this->_M_finish._M_p != this->_M_end_of_storage._M_data) {
368 __copy_backward(__position, this->_M_finish, this->_M_finish + 1, random_access_iterator_tag(), (difference_type*)0 );
373 size_type __len = size() ? 2 * size() : __WORD_BIT;
374 unsigned int* __q = this->_M_bit_alloc(__len);
375 iterator __i = copy(begin(), __position, iterator(__q, 0));
377 this->_M_finish = copy(__position, end(), __i);
378 this->_M_deallocate();
379 this->_M_end_of_storage._M_data = __q + (__len + __WORD_BIT - 1)/__WORD_BIT;
380 this->_M_start = iterator(__q, 0);
384 #ifdef _STLP_MEMBER_TEMPLATES
385 template <class _InputIterator>
386 void _M_initialize_range(_InputIterator __first, _InputIterator __last,
387 const input_iterator_tag &) {
388 this->_M_start = iterator();
389 this->_M_finish = iterator();
390 this->_M_end_of_storage._M_data = 0;
391 for ( ; __first != __last; ++__first)
395 template <class _ForwardIterator>
396 void _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last,
397 const forward_iterator_tag &) {
398 size_type __n = distance(__first, __last);
400 // copy(__first, __last, _M_start);
401 copy(__first, __last, this->_M_start); // dwa 12/22/99 -- resolving ambiguous reference.
404 template <class _InputIterator>
405 void _M_insert_range(iterator __pos,
406 _InputIterator __first, _InputIterator __last,
407 const input_iterator_tag &) {
408 for ( ; __first != __last; ++__first) {
409 __pos = insert(__pos, *__first);
414 template <class _ForwardIterator>
415 void _M_insert_range(iterator __position,
416 _ForwardIterator __first, _ForwardIterator __last,
417 const forward_iterator_tag &) {
418 if (__first != __last) {
419 size_type __n = distance(__first, __last);
420 if (capacity() - size() >= __n) {
421 __copy_backward(__position, end(), this->_M_finish + difference_type(__n), random_access_iterator_tag(), (difference_type*)0 );
422 copy(__first, __last, __position);
423 this->_M_finish += difference_type(__n);
426 size_type __len = size() + (max)(size(), __n);
427 unsigned int* __q = this->_M_bit_alloc(__len);
428 iterator __i = copy(begin(), __position, iterator(__q, 0));
429 __i = copy(__first, __last, __i);
430 this->_M_finish = copy(__position, end(), __i);
431 this->_M_deallocate();
432 this->_M_end_of_storage._M_data = __q + (__len + __WORD_BIT - 1)/__WORD_BIT;
433 this->_M_start = iterator(__q, 0);
438 #endif /* _STLP_MEMBER_TEMPLATES */
441 iterator begin() { return this->_M_start; }
442 const_iterator begin() const { return this->_M_start; }
443 iterator end() { return this->_M_finish; }
444 const_iterator end() const { return this->_M_finish; }
446 reverse_iterator rbegin() { return reverse_iterator(end()); }
447 const_reverse_iterator rbegin() const {
448 return const_reverse_iterator(end());
450 reverse_iterator rend() { return reverse_iterator(begin()); }
451 const_reverse_iterator rend() const {
452 return const_reverse_iterator(begin());
455 size_type size() const { return size_type(end() - begin()); }
456 size_type max_size() const { return size_type(-1); }
457 size_type capacity() const {
458 return size_type(const_iterator(this->_M_end_of_storage._M_data, 0) - begin());
460 bool empty() const { return begin() == end(); }
461 reference operator[](size_type __n)
462 { return *(begin() + difference_type(__n)); }
463 const_reference operator[](size_type __n) const
464 { return *(begin() + difference_type(__n)); }
466 void _M_range_check(size_type __n) const {
467 if (__n >= this->size())
468 __stl_throw_range_error("vector<bool>");
471 reference at(size_type __n)
472 { _M_range_check(__n); return (*this)[__n]; }
473 const_reference at(size_type __n) const
474 { _M_range_check(__n); return (*this)[__n]; }
476 explicit __BVECTOR(const allocator_type& __a = allocator_type())
477 : _Bvector_base<_Alloc >(__a) {
481 __BVECTOR(size_type __n, bool __val,
482 const allocator_type& __a =
484 : _Bvector_base<_Alloc >(__a)
486 _STLP_PUSH_CLEANUP_ITEM(_Base, this)
488 fill(this->_M_start._M_p, (__chunk_type*)(this->_M_end_of_storage._M_data), __val ? ~0 : 0);
489 _STLP_POP_CLEANUP_ITEM
492 explicit __BVECTOR(size_type __n)
493 : _Bvector_base<_Alloc >(allocator_type())
495 _STLP_PUSH_CLEANUP_ITEM(_Base, this)
497 fill(this->_M_start._M_p, (__chunk_type*)(this->_M_end_of_storage._M_data), 0);
498 _STLP_POP_CLEANUP_ITEM
501 __BVECTOR(const _Self& __x) : _Bvector_base<_Alloc >(__x.get_allocator()) {
502 _STLP_PUSH_CLEANUP_ITEM(_Base, this)
503 _M_initialize(__x.size());
504 copy(__x.begin(), __x.end(), this->_M_start);
505 _STLP_POP_CLEANUP_ITEM
508 #if defined (_STLP_MEMBER_TEMPLATES)
509 template <class _Integer>
510 void _M_initialize_dispatch(_Integer __n, _Integer __x, const __true_type&) {
512 fill(this->_M_start._M_p, this->_M_end_of_storage._M_data, __x ? ~0 : 0);
515 template <class _InputIterator>
516 void _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
517 const __false_type&) {
518 _M_initialize_range(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator));
520 # ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS
521 // Check whether it's an integral type. If so, it's not an iterator.
522 template <class _InputIterator>
523 __BVECTOR(_InputIterator __first, _InputIterator __last)
524 : _Base(allocator_type())
526 typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
527 _STLP_PUSH_CLEANUP_ITEM(_Base, this)
528 _M_initialize_dispatch(__first, __last, _Integral());
529 _STLP_POP_CLEANUP_ITEM
532 template <class _InputIterator>
533 __BVECTOR(_InputIterator __first, _InputIterator __last,
534 const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
537 typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
538 _STLP_PUSH_CLEANUP_ITEM(_Base, this)
539 _M_initialize_dispatch(__first, __last, _Integral());
540 _STLP_POP_CLEANUP_ITEM
542 #else /* _STLP_MEMBER_TEMPLATES */
543 __BVECTOR(const_iterator __first, const_iterator __last,
544 const allocator_type& __a = allocator_type())
545 : _Bvector_base<_Alloc >(__a)
547 _STLP_PUSH_CLEANUP_ITEM(_Base, this)
548 size_type __n = distance(__first, __last);
550 copy(__first, __last, this->_M_start);
551 _STLP_POP_CLEANUP_ITEM
553 __BVECTOR(const bool* __first, const bool* __last,
554 const allocator_type& __a = allocator_type())
555 : _Bvector_base<_Alloc >(__a)
557 size_type __n = distance(__first, __last);
558 _STLP_PUSH_CLEANUP_ITEM(_Base, this)
560 copy(__first, __last, this->_M_start);
561 _STLP_POP_CLEANUP_ITEM
563 #endif /* _STLP_MEMBER_TEMPLATES */
567 __BVECTOR_QUALIFIED& operator=(const __BVECTOR_QUALIFIED& __x) {
568 if (&__x == this) return *this;
569 if (__x.size() > capacity()) {
570 this->_M_deallocate();
571 _M_initialize(__x.size());
573 copy(__x.begin(), __x.end(), begin());
574 this->_M_finish = begin() + difference_type(__x.size());
578 #ifdef _STLP_USE_TRAP_LEAVE
580 static void* operator new (size_t __n, TLeave) { return _STLP_StackHelper<bool>::_NewLC(__n); }
581 static void* operator new (size_t __n) { return _STLP_StackHelper<bool>::_NewLC(__n); }
584 // assign(), a generalized assignment member function. Two
585 // versions: one that takes a count, and one that takes a range.
586 // The range version is a member template, so we dispatch on whether
587 // or not the type is an integer.
589 void _M_fill_assign(size_t __n, bool __x) {
591 fill(this->_M_start._M_p, (__chunk_type*)(this->_M_end_of_storage._M_data), __x ? ~0 : 0);
592 insert(end(), __n - size(), __x);
595 erase(begin() + __n, end());
596 fill(this->_M_start._M_p, (__chunk_type*)(this->_M_end_of_storage._M_data), __x ? ~0 : 0);
599 void assign(size_t __n, bool __x) { _M_fill_assign(__n, __x); }
601 #ifdef _STLP_MEMBER_TEMPLATES
603 template <class _InputIterator>
604 void assign(_InputIterator __first, _InputIterator __last) {
605 typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
606 _M_assign_dispatch(__first, __last, _Integral());
609 template <class _Integer>
610 void _M_assign_dispatch(_Integer __n, _Integer __val, const __true_type&)
611 { _M_fill_assign((size_t) __n, (bool) __val); }
613 template <class _InputIter>
614 void _M_assign_dispatch(_InputIter __first, _InputIter __last, const __false_type&)
615 { _M_assign_aux(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIter)); }
617 template <class _InputIterator>
618 void _M_assign_aux(_InputIterator __first, _InputIterator __last,
619 const input_iterator_tag &) {
620 iterator __cur = begin();
621 for ( ; __first != __last && __cur != end(); ++__cur, ++__first)
623 if (__first == __last)
626 insert(end(), __first, __last);
629 template <class _ForwardIterator>
630 void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
631 const forward_iterator_tag &) {
632 size_type __len = distance(__first, __last);
634 erase(copy(__first, __last, begin()), end());
636 _ForwardIterator __mid = __first;
637 advance(__mid, size());
638 copy(__first, __mid, begin());
639 insert(end(), __mid, __last);
643 #endif /* _STLP_MEMBER_TEMPLATES */
645 void reserve(size_type __n) {
646 if (capacity() < __n) {
647 unsigned int* __q = this->_M_bit_alloc(__n);
648 _Bit_iterator __z(__q, 0);
649 this->_M_finish = copy(begin(), end(), __z);
650 this->_M_deallocate();
651 this->_M_start = iterator(__q, 0);
652 this->_M_end_of_storage._M_data = __q + (__n + __WORD_BIT - 1)/__WORD_BIT;
656 reference front() { return *begin(); }
657 const_reference front() const { return *begin(); }
658 reference back() { return *(end() - 1); }
659 const_reference back() const { return *(end() - 1); }
660 void push_back(bool __x) {
661 if (this->_M_finish._M_p != this->_M_end_of_storage._M_data) {
662 *(this->_M_finish) = __x;
666 _M_insert_aux(end(), __x);
668 void swap(__BVECTOR_QUALIFIED& __x) {
669 _STLP_STD::swap(this->_M_start, __x._M_start);
670 _STLP_STD::swap(this->_M_finish, __x._M_finish);
671 _STLP_STD::swap(this->_M_end_of_storage, __x._M_end_of_storage);
673 iterator insert(iterator __position, bool __x = bool()) {
674 difference_type __n = __position - begin();
675 if (this->_M_finish._M_p != this->_M_end_of_storage._M_data && __position == end()) {
676 *(this->_M_finish) = __x;
680 _M_insert_aux(__position, __x);
681 return begin() + __n;
684 #if defined ( _STLP_MEMBER_TEMPLATES )
686 template <class _Integer>
687 void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,
688 const __true_type&) {
689 _M_fill_insert(__pos, (size_type) __n, (bool) __x);
692 template <class _InputIterator>
693 void _M_insert_dispatch(iterator __pos,
694 _InputIterator __first, _InputIterator __last,
695 const __false_type&) {
696 _M_insert_range(__pos, __first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator));
699 // Check whether it's an integral type. If so, it's not an iterator.
700 template <class _InputIterator>
701 void insert(iterator __position,
702 _InputIterator __first, _InputIterator __last) {
703 typedef typename _Is_integer<_InputIterator>::_Integral _Is_Integral;
704 _M_insert_dispatch(__position, __first, __last, _Is_Integral());
706 #else /* _STLP_MEMBER_TEMPLATES */
707 void insert(iterator __position,
708 const_iterator __first, const_iterator __last) {
709 if (__first == __last) return;
710 size_type __n = distance(__first, __last);
711 if (capacity() - size() >= __n) {
712 __copy_backward(__position, end(), this->_M_finish + __n,
713 random_access_iterator_tag(), (difference_type*)0 );
714 copy(__first, __last, __position);
715 this->_M_finish += __n;
718 size_type __len = size() + (max)(size(), __n);
719 unsigned int* __q = this->_M_bit_alloc(__len);
720 iterator __i = copy(begin(), __position, iterator(__q, 0));
721 __i = copy(__first, __last, __i);
722 this->_M_finish = copy(__position, end(), __i);
723 this->_M_deallocate();
724 this->_M_end_of_storage._M_data = __q + (__len + __WORD_BIT - 1)/__WORD_BIT;
725 this->_M_start = iterator(__q, 0);
729 void insert(iterator __position, const bool* __first, const bool* __last) {
730 if (__first == __last) return;
731 size_type __n = distance(__first, __last);
732 if (capacity() - size() >= __n) {
733 __copy_backward(__position, end(), this->_M_finish + __n,
734 random_access_iterator_tag(), (difference_type*)0 );
735 copy(__first, __last, __position);
736 this->_M_finish += __n;
739 size_type __len = size() + (max)(size(), __n);
740 unsigned int* __q = this->_M_bit_alloc(__len);
741 iterator __i = copy(begin(), __position, iterator(__q, 0));
742 __i = copy(__first, __last, __i);
743 this->_M_finish = copy(__position, end(), __i);
744 this->_M_deallocate();
745 this->_M_end_of_storage._M_data = __q + (__len + __WORD_BIT - 1)/__WORD_BIT;
746 this->_M_start = iterator(__q, 0);
749 #endif /* _STLP_MEMBER_TEMPLATES */
751 void _M_fill_insert(iterator __position, size_type __n, bool __x) {
752 if (__n == 0) return;
753 if (capacity() - size() >= __n) {
754 __copy_backward(__position, end(), this->_M_finish + difference_type(__n), random_access_iterator_tag(), (difference_type*)0 );
755 fill(__position, __position + difference_type(__n), __x);
756 this->_M_finish += difference_type(__n);
759 size_type __len = size() + (max)(size(), __n);
760 unsigned int* __q = this->_M_bit_alloc(__len);
761 iterator __i = copy(begin(), __position, iterator(__q, 0));
762 fill_n(__i, __n, __x);
763 this->_M_finish = copy(__position, end(), __i + difference_type(__n));
764 this->_M_deallocate();
765 this->_M_end_of_storage._M_data = __q + (__len + __WORD_BIT - 1)/__WORD_BIT;
766 this->_M_start = iterator(__q, 0);
770 void insert(iterator __position, size_type __n, bool __x) {
771 _M_fill_insert(__position, __n, __x);
777 iterator erase(iterator __position) {
778 if (__position + 1 != end())
779 copy(__position + 1, end(), __position);
783 iterator erase(iterator __first, iterator __last) {
784 this->_M_finish = copy(__last, end(), __first);
787 void resize(size_type __new_size, bool __x = bool()) {
788 if (__new_size < size())
789 erase(begin() + difference_type(__new_size), end());
791 insert(end(), __new_size - size(), __x);
794 for (unsigned int* __p = this->_M_start._M_p; __p != this->_M_end_of_storage._M_data; ++__p)
798 void clear() { erase(begin(), end()); }
801 # if defined ( _STLP_NO_BOOL ) || defined (__HP_aCC) // fixed soon (03/17/2000)
803 #define _STLP_TEMPLATE_HEADER __BVEC_TMPL_HEADER
804 #define _STLP_TEMPLATE_CONTAINER __BVECTOR_QUALIFIED
805 #include <stl/_relops_cont.h>
806 #undef _STLP_TEMPLATE_CONTAINER
807 #undef _STLP_TEMPLATE_HEADER
809 # endif /* NO_BOOL */
811 #if !defined (_STLP_NO_BOOL)
812 // This typedef is non-standard. It is provided for backward compatibility.
813 typedef __WORKAROUND_DBG_RENAME(vector) <bool, allocator<bool> > bit_vector;
819 #undef _STLP_VECBOOL_TEMPLATE
821 #undef __BVECTOR_QUALIFIED
822 #undef __BVEC_TMPL_HEADER
826 #endif /* _STLP_INTERNAL_BVECTOR_H */