Revision | 37d9e2b88f6c7049cd2f4358348f392588b26f16 (tree) |
---|---|
Time | 2013-05-11 12:01:53 |
Author | <exeal@user...> |
detail.GapVector.insert family now returns an iterator which addresses the inserted element.
@@ -3,7 +3,7 @@ | ||
3 | 3 | * @author exeal |
4 | 4 | * @date 2005-2009 (was gap-buffer.hpp) |
5 | 5 | * @date 2010-10-20 Renamed GapBuffer to GapVector. |
6 | - * @date 2011-2012 | |
6 | + * @date 2011-2013 | |
7 | 7 | */ |
8 | 8 | |
9 | 9 | #ifndef ASCENSION_GAP_VECTOR_HPP |
@@ -52,8 +52,8 @@ | ||
52 | 52 | std::random_access_iterator_tag, Reference, typename Target::difference_type> { |
53 | 53 | public: |
54 | 54 | typedef GapVectorIterator<Target, Pointer, Reference> Self; |
55 | - GapVectorIterator() /*noexcept*/ : target_(nullptr) {} | |
56 | - GapVectorIterator(const Target& target, Pointer position) /*noexcept*/ | |
55 | + GapVectorIterator() BOOST_NOEXCEPT : target_(nullptr) {} | |
56 | + GapVectorIterator(const Target& target, Pointer position) BOOST_NOEXCEPT | |
57 | 57 | : target_(&target), current_(position - target.first_) {} |
58 | 58 | template<typename Pointer2, typename Reference2> |
59 | 59 | GapVectorIterator(const GapVectorIterator<Target, Pointer2, Reference2>& other) |
@@ -63,36 +63,36 @@ | ||
63 | 63 | current_ = other.current_; |
64 | 64 | return *this; |
65 | 65 | } |
66 | - const Pointer get() const /*noexcept*/ {return target()->first_ + current_;} | |
67 | - const Target* target() const /*noexcept*/ {return target_;} | |
68 | - private: | |
69 | - difference_type offset() const /*noexcept*/ { | |
66 | + const Pointer get() const BOOST_NOEXCEPT {return target()->first_ + current_;} | |
67 | + difference_type offset() const BOOST_NOEXCEPT { | |
70 | 68 | return (get() <= target_->gapFirst_) ? |
71 | 69 | get() - target_->first_ : |
72 | 70 | get() - target_->gapLast_ + target_->gapFirst_ - target_->first_; |
73 | 71 | } |
72 | + const Target* target() const BOOST_NOEXCEPT {return target_;} | |
73 | + private: | |
74 | 74 | friend class boost::iterator_core_access; |
75 | 75 | void advance(difference_type n) { |
76 | 76 | if(get() + n >= target_->gapFirst_ && get() + n < target_->gapLast_) |
77 | 77 | n += target_->gap(); |
78 | 78 | current_ += n; |
79 | 79 | } |
80 | - void decrement() /*noexcept*/ { | |
80 | + void decrement() BOOST_NOEXCEPT { | |
81 | 81 | if(get() != target_->gapLast_) |
82 | 82 | --current_; |
83 | 83 | else |
84 | 84 | current_ = (target()->gapFirst_ - target()->first_) - 1; |
85 | 85 | } |
86 | - reference dereference() const /*noexcept*/ { | |
86 | + reference dereference() const BOOST_NOEXCEPT { | |
87 | 87 | return target_->first_[current_]; |
88 | 88 | } |
89 | - difference_type distance_to(const GapVectorIterator& other) const /*noexcept*/ { | |
89 | + difference_type distance_to(const GapVectorIterator& other) const BOOST_NOEXCEPT { | |
90 | 90 | return current_ - other.current_; |
91 | 91 | } |
92 | - bool equal(const GapVectorIterator& other) const /*noexcept*/ { | |
92 | + bool equal(const GapVectorIterator& other) const BOOST_NOEXCEPT { | |
93 | 93 | return current_ == current_; |
94 | 94 | } |
95 | - void increment() /*noexcept*/ { | |
95 | + void increment() BOOST_NOEXCEPT { | |
96 | 96 | assert(get() != target_->gapFirst_); |
97 | 97 | ++current_; |
98 | 98 | if(get() == target_->gapFirst_) |
@@ -112,9 +112,6 @@ | ||
112 | 112 | template<typename T, typename Allocator = std::allocator<T>> |
113 | 113 | class GapVector : boost::totally_ordered<GapVector<T, Allocator>> { |
114 | 114 | public: |
115 | - | |
116 | - // member types /////////////////////////////////////////////////////////////////////// | |
117 | - | |
118 | 115 | /// A type represents the allocator class. |
119 | 116 | typedef Allocator allocator_type; |
120 | 117 | /// A type counts the number of elements. |
@@ -141,11 +138,10 @@ | ||
141 | 138 | /// A type provides a random-access iterator can read any element in the content. |
142 | 139 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
143 | 140 | |
144 | - | |
145 | - // core member functions ////////////////////////////////////////////////////////////// | |
146 | - | |
141 | + /// @name Construct/Copy/Destroy | |
142 | + /// @{ | |
147 | 143 | /** |
148 | - * Constructor. | |
144 | + * Constructs an empty gap vector, using the specified allocator. | |
149 | 145 | * @param allocator The allocator object |
150 | 146 | */ |
151 | 147 | explicit GapVector(const allocator_type& allocator = allocator_type()) : |
@@ -155,20 +151,21 @@ | ||
155 | 151 | gapFirst_(first_), gapLast_(last_) {} |
156 | 152 | |
157 | 153 | /** |
158 | - * Constructor specifies repition of a specified number of elements. | |
159 | - * @param count The number of elements in the constructed content | |
154 | + * Constructs a gap vector with @a n copies of value, using the specified allocator. | |
155 | + * @param n The number of elements in the constructed content | |
160 | 156 | * @param value The value of elements in the constructed content |
161 | 157 | * @param allocator The allocator object |
162 | 158 | */ |
163 | - GapVector(size_type count, const_reference value, | |
159 | + GapVector(size_type n, const_reference value, | |
164 | 160 | const allocator_type& allocator = allocator_type()) : allocator_(allocator), |
165 | - first_(allocator_.allocate(count, 0)), last_(first_ + count), | |
161 | + first_(allocator_.allocate(count, 0)), last_(first_ + n), | |
166 | 162 | gapFirst_(first_), gapLast_(last_) { |
167 | - insert(0, count, value); | |
163 | + insert(0, n, value); | |
168 | 164 | } |
169 | 165 | |
170 | 166 | /** |
171 | - * Constructor copies a range of a gap vector. | |
167 | + * Constructs a gap vector equal to the range <code>[first,last)</code>, using the | |
168 | + * specified allocator. | |
172 | 169 | * @tparam Inputiterator The input iterator |
173 | 170 | * @param first The first element in the range of elements to be copied |
174 | 171 | * @param last The last element in the range of elements to be copied |
@@ -247,14 +244,14 @@ | ||
247 | 244 | *p = std::move(other.first_ + (p - first_)); |
248 | 245 | other.first_ = other.last_ = other.gapFirst_ = other.gapLast_ = nullptr; |
249 | 246 | } |
250 | - | |
247 | +#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST | |
251 | 248 | /** |
252 | 249 | * Constructor with an initializer list. |
253 | 250 | * @param values The initializer list to initialize the elements of the container with |
254 | 251 | * @param allocator The allocator object |
255 | 252 | */ |
256 | 253 | GapVector(std::initializer_list<value_type> values, const allocator_type& allocator); |
257 | - | |
254 | +#endif // !BOOST_NO_CXX11_HDR_INITIALIZER_LIST | |
258 | 255 | /// Destructor. |
259 | 256 | ~GapVector() {release();} |
260 | 257 |
@@ -277,7 +274,9 @@ | ||
277 | 274 | GapVector<value_type, allocator_type>(std::forward(other)).swap(*this); |
278 | 275 | return *this; |
279 | 276 | } |
280 | - | |
277 | +#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST | |
278 | + GapVector& operator=(std::initializer_list<value_type> values); | |
279 | +#endif // !BOOST_NO_CXX11_HDR_INITIALIZER_LIST | |
281 | 280 | /** |
282 | 281 | * Assigns a range of elements. |
283 | 282 | * @tparam InputIterator The input iterator type gives the range |
@@ -292,20 +291,24 @@ | ||
292 | 291 | |
293 | 292 | /** |
294 | 293 | * Assigns a number of elements. |
295 | - * @param count The new size of the container | |
294 | + * @param n The new size of the container | |
296 | 295 | * @param value The value to initialize elements of the container with |
297 | 296 | */ |
298 | - void assign(size_type count, const_reference value) { | |
299 | - GapVector<value_type, allocator_type> temp(count, value); | |
297 | + void assign(size_type n, const_reference value) { | |
298 | + GapVector<value_type, allocator_type> temp(n, value); | |
300 | 299 | *this = std::move(temp); |
301 | 300 | } |
301 | +#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST | |
302 | + void assign(std::initializer_list<value_type> values); | |
303 | +#endif // !BOOST_NO_CXX11_HDR_INITIALIZER_LIST | |
302 | 304 | |
303 | 305 | /// Returns the allocator associated with the container. |
304 | 306 | allocator_type allocator() const {return allocator_;} |
307 | + /// @} | |
305 | 308 | |
306 | 309 | |
307 | - // element accesses /////////////////////////////////////////////////////////////////// | |
308 | - | |
310 | + /// @name Element Access | |
311 | + /// @{ | |
309 | 312 | /** |
310 | 313 | * Returns a reference to the element at a specified position. |
311 | 314 | * @param position The position of the element to return |
@@ -335,7 +338,7 @@ | ||
335 | 338 | * @param position The position of the element to return |
336 | 339 | * @return A reference to the requested element |
337 | 340 | */ |
338 | - reference operator[](size_type position) /*throw()*/ { | |
341 | + reference operator[](size_type position) BOOST_NOEXCEPT { | |
339 | 342 | return first_[(first_ + position < gapFirst_) ? position : position + gap()]; |
340 | 343 | } |
341 | 344 |
@@ -344,75 +347,75 @@ | ||
344 | 347 | * @param position The position of the element to return |
345 | 348 | * @return A reference to the requested element |
346 | 349 | */ |
347 | - const_reference operator[](size_type position) const /*throw()*/ { | |
350 | + const_reference operator[](size_type position) const BOOST_NOEXCEPT { | |
348 | 351 | return first_[(first_ + position < gapFirst_) ? position : position + gap()]; |
349 | 352 | } |
350 | 353 | |
351 | 354 | /// Returns a reference to the first element in the container. |
352 | - reference front() /*throw()*/ {return (*this)[0];} | |
355 | + reference front() BOOST_NOEXCEPT {return (*this)[0];} | |
353 | 356 | |
354 | 357 | /// Returns a reference to the first element in the container. |
355 | - const_reference front() const /*throw()*/ {return (*this)[0];} | |
358 | + const_reference front() const BOOST_NOEXCEPT {return (*this)[0];} | |
356 | 359 | |
357 | 360 | /// Returns a reference to the last element in the container. |
358 | - reference back() /*throw()*/ {return (*this)[size() - 1];} | |
361 | + reference back() BOOST_NOEXCEPT {return (*this)[size() - 1];} | |
359 | 362 | |
360 | 363 | /// Returns a const reference to the last element in the container. |
361 | - const_reference back() const /*throw()*/ {return (*this)[size() - 1];} | |
362 | - | |
364 | + const_reference back() const BOOST_NOEXCEPT {return (*this)[size() - 1];} | |
365 | + /// @} | |
363 | 366 | |
364 | - // iterators ////////////////////////////////////////////////////////////////////////// | |
365 | - | |
366 | - /// Returns an iterator to the first element of the container. | |
367 | - iterator begin() /*noexcept*/ {return iterator(*this, first_);} | |
367 | + /// @name Iterators | |
368 | + /// @{ | |
369 | + /** Returns an iterator to the first element of the container. */ | |
370 | + iterator begin() BOOST_NOEXCEPT {return iterator(*this, first_);} | |
368 | 371 | |
369 | 372 | /// Returns an iterator to the first element of the container. |
370 | - const_iterator begin() const /*noexcept*/ {return const_iterator(*this, first_);} | |
373 | + const_iterator begin() const BOOST_NOEXCEPT {return const_iterator(*this, first_);} | |
371 | 374 | |
372 | 375 | /// Returns an iterator to the first element of the container. |
373 | - const_iterator cbegin() const /*noexcept*/ {return begin();} | |
374 | - | |
375 | - /// Returns an iterator to the element following the last element of the container. | |
376 | - iterator end() /*noexcept*/ {return iterator(*this, last_);} | |
376 | + const_iterator cbegin() const BOOST_NOEXCEPT {return begin();} | |
377 | 377 | |
378 | 378 | /// Returns an iterator to the element following the last element of the container. |
379 | - const_iterator end() const /*noexcept*/ {return const_iterator(*this, last_);} | |
379 | + iterator end() BOOST_NOEXCEPT {return iterator(*this, last_);} | |
380 | 380 | |
381 | 381 | /// Returns an iterator to the element following the last element of the container. |
382 | - const_iterator cend() const /*noexcept*/ {return end();} | |
382 | + const_iterator end() const BOOST_NOEXCEPT {return const_iterator(*this, last_);} | |
383 | + | |
384 | + /// Returns an iterator to the element following the last element of the container. | |
385 | + const_iterator cend() const BOOST_NOEXCEPT {return end();} | |
383 | 386 | |
384 | 387 | /// Returns a reverse iterator to the first element of the reversed container. |
385 | - reverse_iterator rbegin() /*noexcept*/ {return reverse_iterator(end());} | |
388 | + reverse_iterator rbegin() BOOST_NOEXCEPT {return reverse_iterator(end());} | |
386 | 389 | |
387 | 390 | /// Returns a reverse iterator to the first element of the reversed container. |
388 | - const_reverse_iterator rbegin() const /*noexcept*/ {return const_reverse_iterator(end());} | |
391 | + const_reverse_iterator rbegin() const BOOST_NOEXCEPT {return const_reverse_iterator(end());} | |
389 | 392 | |
390 | 393 | /// Returns a reverse iterator to the first element of the reversed container. |
391 | - const_reverse_iterator crbegin() const /*noexcept*/ {return rbegin();} | |
394 | + const_reverse_iterator crbegin() const BOOST_NOEXCEPT {return rbegin();} | |
392 | 395 | |
393 | 396 | /// Returns a reverse iterator to the element following the last element of the |
394 | 397 | /// reversed container. |
395 | - reverse_iterator rend() /*noexcept*/ {return reverse_iterator(begin());} | |
396 | - | |
397 | - /// Returns a reverse iterator to the element following the last element of the | |
398 | - /// reversed container. | |
399 | - const_reverse_iterator rend() const /*noexcept*/ {return const_reverse_iterator(begin());} | |
398 | + reverse_iterator rend() BOOST_NOEXCEPT {return reverse_iterator(begin());} | |
400 | 399 | |
401 | 400 | /// Returns a reverse iterator to the element following the last element of the |
402 | 401 | /// reversed container. |
403 | - const_reverse_iterator crend() const /*noexcept*/ {return rend();} | |
404 | - | |
402 | + const_reverse_iterator rend() const BOOST_NOEXCEPT {return const_reverse_iterator(begin());} | |
405 | 403 | |
406 | - // capacities ///////////////////////////////////////////////////////////////////////// | |
404 | + /// Returns a reverse iterator to the element following the last element of the | |
405 | + /// reversed container. | |
406 | + const_reverse_iterator crend() const BOOST_NOEXCEPT {return rend();} | |
407 | 407 | |
408 | - /// Returns @c true if the container is empty. | |
409 | - bool empty() const /*noexcept*/ {return size() == 0;} | |
408 | + /// @name Capacity | |
409 | + /// @note @c GapVector does not provide @c resize methods. | |
410 | + /// @{ | |
411 | + /** Returns @c true if the container is empty. */ | |
412 | + bool empty() const BOOST_NOEXCEPT {return size() == 0;} | |
410 | 413 | |
411 | 414 | /// Returns the number of elements in the container. |
412 | - size_type size() const /*noexcept*/ {return capacity() - gap();} | |
415 | + size_type size() const BOOST_NOEXCEPT {return capacity() - gap();} | |
413 | 416 | |
414 | 417 | /// Returns the maximum size of the container. |
415 | - size_type maxSize() const /*noexcept*/ {return allocator_.max_size();} | |
418 | + size_type maxSize() const BOOST_NOEXCEPT {return allocator_.max_size();} | |
416 | 419 | |
417 | 420 | /** |
418 | 421 | * Sets the capacity of the container to at least @a size. |
@@ -420,15 +423,28 @@ | ||
420 | 423 | */ |
421 | 424 | void reserve(size_type newCapacity) {reallocate(newCapacity);} |
422 | 425 | |
423 | - /// Returns the number of elements that the content could contain without allocating | |
424 | - /// more storage. | |
425 | - size_type capacity() const /*noexcept*/ {return last_ - first_;} | |
426 | + /** | |
427 | + * Resizes the container to contain @a count elements. | |
428 | + * @param count The new size of the container | |
429 | + */ | |
430 | + void resize(size_type size); | |
431 | + | |
432 | + /** | |
433 | + * Resizes the container to contain @a count elements. | |
434 | + * @param count The new size of the container | |
435 | + * @param value The value to initialize the new elements with | |
436 | + */ | |
437 | + void resize(size_type count, const_reference value); | |
438 | + | |
439 | + /// Returns the total number of elements that the gap vector can hold without requiring reallocation. | |
440 | + size_type capacity() const BOOST_NOEXCEPT {return last_ - first_;} | |
426 | 441 | |
427 | 442 | /// Requests the removal of unused capacity. |
428 | 443 | void shrinkToFit() {reallocate(size());} |
444 | + /// @} | |
429 | 445 | |
430 | - | |
431 | - // modifiers ////////////////////////////////////////////////////////////////////////// | |
446 | + /// @name Modifiers | |
447 | + /// @{ | |
432 | 448 | |
433 | 449 | /// Removes all elements from the container. |
434 | 450 | void clear() {erase(begin(), end());} // TODO: Follow std.vector.clear semantics. |
@@ -438,11 +454,12 @@ | ||
438 | 454 | * @param position The element before which the content will be inserted |
439 | 455 | * @param value The element value to insert |
440 | 456 | */ |
441 | - void insert(const_iterator position, const_reference value) { | |
457 | + iterator insert(const_iterator position, const_reference value) { | |
442 | 458 | makeGapAt(position.get()); |
443 | 459 | *(gapFirst_++) = value; |
444 | 460 | if(gapFirst_ == gapLast_) |
445 | 461 | reallocate(capacity() * 2); |
462 | + return iterator(*this, gapFirst_); | |
446 | 463 | } |
447 | 464 | |
448 | 465 | /** |
@@ -450,26 +467,28 @@ | ||
450 | 467 | * @param position The element before which the content will be inserted |
451 | 468 | * @param value The element value to insert |
452 | 469 | */ |
453 | - void insert(const_iterator position, value_type&& value) { | |
470 | + iterator insert(const_iterator position, value_type&& value) { | |
454 | 471 | makeGapAt(position.get()); |
455 | 472 | *(gapFirst_++) = std::move(value); |
456 | 473 | if(gapFirst_ == gapLast_) |
457 | 474 | reallocate(capacity() * 2); |
475 | + return iterator(*this, gapFirst_); | |
458 | 476 | } |
459 | 477 | |
460 | 478 | /** |
461 | 479 | * Inserts elements to the specified position in the container. |
462 | 480 | * @param position The element before which the content will be inserted |
463 | - * @param count The number of the elements to insert | |
481 | + * @param n The number of the elements to insert | |
464 | 482 | * @param value The element value to insert |
465 | 483 | */ |
466 | - void insert(const_iterator position, size_type count, const_reference value) { | |
484 | + iterator insert(const_iterator position, size_type n, const_reference value) { | |
467 | 485 | makeGapAt(first_ + size()); |
468 | 486 | makeGapAt(position.get()); |
469 | 487 | if(static_cast<size_type>(gap()) <= count) |
470 | - reallocate(std::max(capacity() + count + 1, capacity() * 2)); | |
471 | - std::fill_n(gapFirst_, count, value); | |
472 | - gapFirst_ += count; | |
488 | + reallocate(std::max(capacity() + n + 1, capacity() * 2)); | |
489 | + std::fill_n(gapFirst_, n, value); | |
490 | + gapFirst_ += n; | |
491 | + return iterator(*this, gapFirst_ - n); | |
473 | 492 | } |
474 | 493 | |
475 | 494 | /** |
@@ -480,28 +499,29 @@ | ||
480 | 499 | * @param last The end of the range of elements to insert |
481 | 500 | */ |
482 | 501 | template<typename InputIterator> |
483 | - void insert(const_iterator position, InputIterator first, InputIterator last) { | |
484 | - const difference_type c = std::distance(first, last); | |
485 | - if(c != 0) { | |
486 | - if(c > gap()) | |
487 | - reallocate(std::max(c + size(), capacity() * 2)); | |
488 | -// makeGapAt(first_ + size()); | |
489 | - makeGapAt(position.get()); | |
490 | - pointer p = const_cast<pointer>(position.get()); | |
491 | - gapFirst_ = first_ + (uninitializedCopy(first, last, p, allocator_) - first_); | |
502 | + iterator insert(const_iterator position, InputIterator first, InputIterator last) { | |
503 | + const difference_type n = std::distance(first, last); | |
504 | + if(n == 0) | |
505 | + return position; | |
506 | + if(n > gap()) { | |
507 | + const const_iterator::difference_type index = position.offset(); | |
508 | + reallocate(std::max(n + size(), capacity() * 2)); | |
509 | + position = cbegin() + index; | |
492 | 510 | } |
511 | +// makeGapAt(first_ + size()); | |
512 | + makeGapAt(position.get()); | |
513 | + pointer p = const_cast<pointer>(position.get()); | |
514 | + gapFirst_ = first_ + (uninitializedCopy(first, last, p, allocator_) - first_); | |
515 | + return iterator(*this, gapFirst_ - n); | |
493 | 516 | } |
494 | - | |
517 | +#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST | |
495 | 518 | /** |
496 | 519 | * Inserts elements to the specified position in the container. |
497 | 520 | * @param position The element before which the content will be inserted |
498 | 521 | * @param values The initializer list to insert the values from |
499 | 522 | */ |
500 | - void insert(const_iterator position, std::initializer_list<value_type> values); | |
501 | - | |
502 | -// template<typename... Arguments> | |
503 | -// iterator emplace(const_iterator position, Arguments&& ...arguments); | |
504 | - | |
523 | + iterator insert(const_iterator position, std::initializer_list<value_type> values); | |
524 | +#endif // !BOOST_NO_CXX11_HDR_INITIALIZER_LIST | |
505 | 525 | /** |
506 | 526 | * Removes an element in this gap vector. |
507 | 527 | * @param position The position of the element to remove |
@@ -539,33 +559,24 @@ | ||
539 | 559 | |
540 | 560 | void pushBack(const_reference value); |
541 | 561 | void pushBack(value_type&& value); |
542 | -// template<typename... Arguments> void emplaceBack(Arguments&& ...arguments); | |
562 | +#ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES | |
563 | + template<typename... Arguments> void emplace(const_iterator position, Arguments&& ...arguments); | |
564 | + template<typename... Arguments> void emplaceBack(Arguments&& ...arguments); | |
565 | +#endif // !BOOST_NO_CXX11_VARIADIC_TEMPLATES | |
543 | 566 | void popBack(); |
544 | 567 | |
545 | 568 | /** |
546 | - * Resizes the container to contain @a count elements. | |
547 | - * @param count The new size of the container | |
548 | - */ | |
549 | - void resize(size_type size); | |
550 | - | |
551 | - /** | |
552 | - * Resizes the container to contain @a count elements. | |
553 | - * @param count The new size of the container | |
554 | - * @param value The value to initialize the new elements with | |
555 | - */ | |
556 | - void resize(size_type count, const_reference value); | |
557 | - | |
558 | - /** | |
559 | 569 | * Exchanges the elements of two gap vectors. |
560 | 570 | * @param other A gap vector whose elements to be exchanged |
561 | 571 | */ |
562 | - void swap(GapVector& other) /*noexcept*/ { | |
572 | + void swap(GapVector& other) BOOST_NOEXCEPT { | |
563 | 573 | std::swap(allocator_, other.allocator); |
564 | 574 | std::swap(first_, other.first_); |
565 | 575 | std::swap(last_, other.last_); |
566 | 576 | std::swap(gapFirst_, other.gapFirst_); |
567 | 577 | std::swap(gapLast_, other.gapLast_); |
568 | 578 | } |
579 | + /// @} | |
569 | 580 | |
570 | 581 | private: |
571 | 582 | // helpers |
@@ -573,7 +584,7 @@ | ||
573 | 584 | for(; first != last; ++first) |
574 | 585 | allocator_.destroy(first); |
575 | 586 | } |
576 | - difference_type gap() const /*throw()*/ {return gapLast_ - gapFirst_;} | |
587 | + difference_type gap() const BOOST_NOEXCEPT {return gapLast_ - gapFirst_;} | |
577 | 588 | void makeGapAt(const_pointer position) { |
578 | 589 | pointer p = const_cast<pointer>(position); |
579 | 590 | if(position < gapFirst_) { |
@@ -617,6 +628,7 @@ | ||
617 | 628 | gapFirst_ += n; |
618 | 629 | gapLast_ += n; |
619 | 630 | } |
631 | + assert(gapFirst_ == position); | |
620 | 632 | } |
621 | 633 | void reallocate(size_type newCapacity) { |
622 | 634 | if(newCapacity > maxSize()) |