1 // Vector implementation -*- C++ -*-
3 // Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
33 * Hewlett-Packard Company
35 * Permission to use, copy, modify, distribute and sell this software
36 * and its documentation for any purpose is hereby granted without fee,
37 * provided that the above copyright notice appear in all copies and
38 * that both that copyright notice and this permission notice appear
39 * in supporting documentation. Hewlett-Packard Company makes no
40 * representations about the suitability of this software for any
41 * purpose. It is provided "as is" without express or implied warranty.
45 * Silicon Graphics Computer Systems, Inc.
47 * Permission to use, copy, modify, distribute and sell this software
48 * and its documentation for any purpose is hereby granted without fee,
49 * provided that the above copyright notice appear in all copies and
50 * that both that copyright notice and this permission notice appear
51 * in supporting documentation. Silicon Graphics makes no
52 * representations about the suitability of this software for any
53 * purpose. It is provided "as is" without express or implied warranty.
56 /** @file stl_vector.h
57 * This is an internal header file, included by other library headers.
58 * You should not attempt to use it directly.
64 #include <bits/stl_iterator_base_funcs.h>
65 #include <bits/functexcept.h>
66 #include <bits/concept_check.h>
72 * See bits/stl_deque.h's _Deque_base for an explanation.
75 template<typename _Tp, typename _Alloc>
80 typedef _Alloc allocator_type;
83 get_allocator() const { return *static_cast<const _Alloc*>(this); }
85 _Vector_base(const allocator_type& __a)
86 : _Alloc(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0) { }
88 _Vector_base(size_t __n, const allocator_type& __a)
91 this->_M_start = this->_M_allocate(__n);
92 this->_M_finish = this->_M_start;
93 this->_M_end_of_storage = this->_M_start + __n;
97 { _M_deallocate(this->_M_start,
98 this->_M_end_of_storage - this->_M_start); }
103 _Tp* _M_end_of_storage;
106 _M_allocate(size_t __n) { return _Alloc::allocate(__n); }
109 _M_deallocate(_Tp* __p, size_t __n)
110 { if (__p) _Alloc::deallocate(__p, __n); }
115 * @brief A standard container which offers fixed time access to
116 * individual elements in any order.
118 * @ingroup Containers
121 * Meets the requirements of a <a href="tables.html#65">container</a>, a
122 * <a href="tables.html#66">reversible container</a>, and a
123 * <a href="tables.html#67">sequence</a>, including the
124 * <a href="tables.html#68">optional sequence requirements</a> with the
125 * %exception of @c push_front and @c pop_front.
127 * In some terminology a %vector can be described as a dynamic
128 * C-style array, it offers fast and efficient access to individual
129 * elements in any order and saves the user from worrying about
130 * memory and size allocation. Subscripting ( @c [] ) access is
131 * also provided as with C-style arrays.
133 template<typename _Tp, typename _Alloc = allocator<_Tp> >
134 class vector : protected _Vector_base<_Tp, _Alloc>
136 // Concept requirements.
137 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
139 typedef _Vector_base<_Tp, _Alloc> _Base;
140 typedef vector<_Tp, _Alloc> vector_type;
143 typedef _Tp value_type;
144 typedef value_type* pointer;
145 typedef const value_type* const_pointer;
146 typedef __gnu_cxx::__normal_iterator<pointer, vector_type> iterator;
147 typedef __gnu_cxx::__normal_iterator<const_pointer, vector_type>
149 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
150 typedef std::reverse_iterator<iterator> reverse_iterator;
151 typedef value_type& reference;
152 typedef const value_type& const_reference;
153 typedef size_t size_type;
154 typedef ptrdiff_t difference_type;
155 typedef typename _Base::allocator_type allocator_type;
159 * These two functions and three data members are all from the
160 * base class. They should be pretty self-explanatory, as
161 * %vector uses a simple contiguous allocation scheme. @endif
163 using _Base::_M_allocate;
164 using _Base::_M_deallocate;
165 using _Base::_M_start;
166 using _Base::_M_finish;
167 using _Base::_M_end_of_storage;
170 // [23.2.4.1] construct/copy/destroy
171 // (assign() and get_allocator() are also listed in this section)
173 * @brief Default constructor creates no elements.
176 vector(const allocator_type& __a = allocator_type())
180 * @brief Create a %vector with copies of an exemplar element.
181 * @param n The number of elements to initially create.
182 * @param value An element to copy.
184 * This constructor fills the %vector with @a n copies of @a value.
186 vector(size_type __n, const value_type& __value,
187 const allocator_type& __a = allocator_type())
189 { this->_M_finish = std::uninitialized_fill_n(this->_M_start,
193 * @brief Create a %vector with default elements.
194 * @param n The number of elements to initially create.
196 * This constructor fills the %vector with @a n copies of a
197 * default-constructed element.
200 vector(size_type __n)
201 : _Base(__n, allocator_type())
202 { this->_M_finish = std::uninitialized_fill_n(this->_M_start,
203 __n, value_type()); }
206 * @brief %Vector copy constructor.
207 * @param x A %vector of identical element and allocator types.
209 * The newly-created %vector uses a copy of the allocation
210 * object used by @a x. All the elements of @a x are copied,
211 * but any extra memory in
212 * @a x (for fast expansion) will not be copied.
214 vector(const vector& __x)
215 : _Base(__x.size(), __x.get_allocator())
216 { this->_M_finish = std::uninitialized_copy(__x.begin(), __x.end(),
221 * @brief Builds a %vector from a range.
222 * @param first An input iterator.
223 * @param last An input iterator.
225 * Create a %vector consisting of copies of the elements from
228 * If the iterators are forward, bidirectional, or
229 * random-access, then this will call the elements' copy
230 * constructor N times (where N is distance(first,last)) and do
231 * no memory reallocation. But if only input iterators are
232 * used, then this will do at most 2N calls to the copy
233 * constructor, and logN memory reallocations.
235 template<typename _InputIterator>
236 vector(_InputIterator __first, _InputIterator __last,
237 const allocator_type& __a = allocator_type())
240 // Check whether it's an integral type. If so, it's not an iterator.
241 typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
242 _M_initialize_dispatch(__first, __last, _Integral());
246 * The dtor only erases the elements, and note that if the
247 * elements themselves are pointers, the pointed-to memory is
248 * not touched in any way. Managing the pointer is the user's
251 ~vector() { std::_Destroy(this->_M_start, this->_M_finish); }
254 * @brief %Vector assignment operator.
255 * @param x A %vector of identical element and allocator types.
257 * All the elements of @a x are copied, but any extra memory in
258 * @a x (for fast expansion) will not be copied. Unlike the
259 * copy constructor, the allocator object is not copied.
262 operator=(const vector& __x);
265 * @brief Assigns a given value to a %vector.
266 * @param n Number of elements to be assigned.
267 * @param val Value to be assigned.
269 * This function fills a %vector with @a n copies of the given
270 * value. Note that the assignment completely changes the
271 * %vector and that the resulting %vector's size is the same as
272 * the number of elements assigned. Old data may be lost.
275 assign(size_type __n, const value_type& __val)
276 { _M_fill_assign(__n, __val); }
279 * @brief Assigns a range to a %vector.
280 * @param first An input iterator.
281 * @param last An input iterator.
283 * This function fills a %vector with copies of the elements in the
284 * range [first,last).
286 * Note that the assignment completely changes the %vector and
287 * that the resulting %vector's size is the same as the number
288 * of elements assigned. Old data may be lost.
290 template<typename _InputIterator>
292 assign(_InputIterator __first, _InputIterator __last)
294 // Check whether it's an integral type. If so, it's not an iterator.
295 typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
296 _M_assign_dispatch(__first, __last, _Integral());
299 /// Get a copy of the memory allocation object.
300 using _Base::get_allocator;
304 * Returns a read/write iterator that points to the first
305 * element in the %vector. Iteration is done in ordinary
309 begin() { return iterator (this->_M_start); }
312 * Returns a read-only (constant) iterator that points to the
313 * first element in the %vector. Iteration is done in ordinary
317 begin() const { return const_iterator (this->_M_start); }
320 * Returns a read/write iterator that points one past the last
321 * element in the %vector. Iteration is done in ordinary
325 end() { return iterator (this->_M_finish); }
328 * Returns a read-only (constant) iterator that points one past
329 * the last element in the %vector. Iteration is done in
330 * ordinary element order.
333 end() const { return const_iterator (this->_M_finish); }
336 * Returns a read/write reverse iterator that points to the
337 * last element in the %vector. Iteration is done in reverse
341 rbegin() { return reverse_iterator(end()); }
344 * Returns a read-only (constant) reverse iterator that points
345 * to the last element in the %vector. Iteration is done in
346 * reverse element order.
348 const_reverse_iterator
349 rbegin() const { return const_reverse_iterator(end()); }
352 * Returns a read/write reverse iterator that points to one
353 * before the first element in the %vector. Iteration is done
354 * in reverse element order.
357 rend() { return reverse_iterator(begin()); }
360 * Returns a read-only (constant) reverse iterator that points
361 * to one before the first element in the %vector. Iteration
362 * is done in reverse element order.
364 const_reverse_iterator
365 rend() const { return const_reverse_iterator(begin()); }
367 // [23.2.4.2] capacity
368 /** Returns the number of elements in the %vector. */
370 size() const { return size_type(end() - begin()); }
372 /** Returns the size() of the largest possible %vector. */
374 max_size() const { return size_type(-1) / sizeof(value_type); }
377 * @brief Resizes the %vector to the specified number of elements.
378 * @param new_size Number of elements the %vector should contain.
379 * @param x Data with which new elements should be populated.
381 * This function will %resize the %vector to the specified
382 * number of elements. If the number is smaller than the
383 * %vector's current size the %vector is truncated, otherwise
384 * the %vector is extended and new elements are populated with
388 resize(size_type __new_size, const value_type& __x)
390 if (__new_size < size())
391 erase(begin() + __new_size, end());
393 insert(end(), __new_size - size(), __x);
397 * @brief Resizes the %vector to the specified number of elements.
398 * @param new_size Number of elements the %vector should contain.
400 * This function will resize the %vector to the specified
401 * number of elements. If the number is smaller than the
402 * %vector's current size the %vector is truncated, otherwise
403 * the %vector is extended and new elements are
404 * default-constructed.
407 resize(size_type __new_size) { resize(__new_size, value_type()); }
410 * Returns the total number of elements that the %vector can
411 * hold before needing to allocate more memory.
415 { return size_type(const_iterator(this->_M_end_of_storage) - begin()); }
418 * Returns true if the %vector is empty. (Thus begin() would
422 empty() const { return begin() == end(); }
425 * @brief Attempt to preallocate enough memory for specified number of
427 * @param n Number of elements required.
428 * @throw std::length_error If @a n exceeds @c max_size().
430 * This function attempts to reserve enough memory for the
431 * %vector to hold the specified number of elements. If the
432 * number requested is more than max_size(), length_error is
435 * The advantage of this function is that if optimal code is a
436 * necessity and the user can determine the number of elements
437 * that will be required, the user can reserve the memory in
438 * %advance, and thus prevent a possible reallocation of memory
439 * and copying of %vector data.
442 reserve(size_type __n);
446 * @brief Subscript access to the data contained in the %vector.
447 * @param n The index of the element for which data should be
449 * @return Read/write reference to data.
451 * This operator allows for easy, array-style, data access.
452 * Note that data access with this operator is unchecked and
453 * out_of_range lookups are not defined. (For checked lookups
457 operator[](size_type __n) { return *(begin() + __n); }
460 * @brief Subscript access to the data contained in the %vector.
461 * @param n The index of the element for which data should be
463 * @return Read-only (constant) reference to data.
465 * This operator allows for easy, array-style, data access.
466 * Note that data access with this operator is unchecked and
467 * out_of_range lookups are not defined. (For checked lookups
471 operator[](size_type __n) const { return *(begin() + __n); }
474 /// @if maint Safety check used only from at(). @endif
476 _M_range_check(size_type __n) const
478 if (__n >= this->size())
479 __throw_out_of_range(__N("vector::_M_range_check"));
484 * @brief Provides access to the data contained in the %vector.
485 * @param n The index of the element for which data should be
487 * @return Read/write reference to data.
488 * @throw std::out_of_range If @a n is an invalid index.
490 * This function provides for safer data access. The parameter
491 * is first checked that it is in the range of the vector. The
492 * function throws out_of_range if the check fails.
495 at(size_type __n) { _M_range_check(__n); return (*this)[__n]; }
498 * @brief Provides access to the data contained in the %vector.
499 * @param n The index of the element for which data should be
501 * @return Read-only (constant) reference to data.
502 * @throw std::out_of_range If @a n is an invalid index.
504 * This function provides for safer data access. The parameter
505 * is first checked that it is in the range of the vector. The
506 * function throws out_of_range if the check fails.
509 at(size_type __n) const { _M_range_check(__n); return (*this)[__n]; }
512 * Returns a read/write reference to the data at the first
513 * element of the %vector.
516 front() { return *begin(); }
519 * Returns a read-only (constant) reference to the data at the first
520 * element of the %vector.
523 front() const { return *begin(); }
526 * Returns a read/write reference to the data at the last
527 * element of the %vector.
530 back() { return *(end() - 1); }
533 * Returns a read-only (constant) reference to the data at the
534 * last element of the %vector.
537 back() const { return *(end() - 1); }
539 // [23.2.4.3] modifiers
541 * @brief Add data to the end of the %vector.
542 * @param x Data to be added.
544 * This is a typical stack operation. The function creates an
545 * element at the end of the %vector and assigns the given data
546 * to it. Due to the nature of a %vector this operation can be
547 * done in constant time if the %vector has preallocated space
551 push_back(const value_type& __x)
553 if (this->_M_finish != this->_M_end_of_storage)
555 std::_Construct(this->_M_finish, __x);
559 _M_insert_aux(end(), __x);
563 * @brief Removes last element.
565 * This is a typical stack operation. It shrinks the %vector by one.
567 * Note that no data is returned, and if the last element's
568 * data is needed, it should be retrieved before pop_back() is
575 std::_Destroy(this->_M_finish);
579 * @brief Inserts given value into %vector before specified iterator.
580 * @param position An iterator into the %vector.
581 * @param x Data to be inserted.
582 * @return An iterator that points to the inserted data.
584 * This function will insert a copy of the given value before
585 * the specified location. Note that this kind of operation
586 * could be expensive for a %vector and if it is frequently
587 * used the user should consider using std::list.
590 insert(iterator __position, const value_type& __x);
593 * @brief Inserts a number of copies of given data into the %vector.
594 * @param position An iterator into the %vector.
595 * @param n Number of elements to be inserted.
596 * @param x Data to be inserted.
598 * This function will insert a specified number of copies of
599 * the given data before the location specified by @a position.
601 * Note that this kind of operation could be expensive for a
602 * %vector and if it is frequently used the user should
603 * consider using std::list.
606 insert(iterator __position, size_type __n, const value_type& __x)
607 { _M_fill_insert(__position, __n, __x); }
610 * @brief Inserts a range into the %vector.
611 * @param position An iterator into the %vector.
612 * @param first An input iterator.
613 * @param last An input iterator.
615 * This function will insert copies of the data in the range
616 * [first,last) into the %vector before the location specified
619 * Note that this kind of operation could be expensive for a
620 * %vector and if it is frequently used the user should
621 * consider using std::list.
623 template<typename _InputIterator>
625 insert(iterator __position, _InputIterator __first,
626 _InputIterator __last)
628 // Check whether it's an integral type. If so, it's not an iterator.
629 typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
630 _M_insert_dispatch(__position, __first, __last, _Integral());
634 * @brief Remove element at given position.
635 * @param position Iterator pointing to element to be erased.
636 * @return An iterator pointing to the next element (or end()).
638 * This function will erase the element at the given position and thus
639 * shorten the %vector by one.
641 * Note This operation could be expensive and if it is
642 * frequently used the user should consider using std::list.
643 * The user is also cautioned that this function only erases
644 * the element, and that if the element is itself a pointer,
645 * the pointed-to memory is not touched in any way. Managing
646 * the pointer is the user's responsibilty.
649 erase(iterator __position);
652 * @brief Remove a range of elements.
653 * @param first Iterator pointing to the first element to be erased.
654 * @param last Iterator pointing to one past the last element to be
656 * @return An iterator pointing to the element pointed to by @a last
657 * prior to erasing (or end()).
659 * This function will erase the elements in the range [first,last) and
660 * shorten the %vector accordingly.
662 * Note This operation could be expensive and if it is
663 * frequently used the user should consider using std::list.
664 * The user is also cautioned that this function only erases
665 * the elements, and that if the elements themselves are
666 * pointers, the pointed-to memory is not touched in any way.
667 * Managing the pointer is the user's responsibilty.
670 erase(iterator __first, iterator __last);
673 * @brief Swaps data with another %vector.
674 * @param x A %vector of the same element and allocator types.
676 * This exchanges the elements between two vectors in constant time.
677 * (Three pointers, so it should be quite fast.)
678 * Note that the global std::swap() function is specialized such that
679 * std::swap(v1,v2) will feed to this function.
684 std::swap(this->_M_start, __x._M_start);
685 std::swap(this->_M_finish, __x._M_finish);
686 std::swap(this->_M_end_of_storage, __x._M_end_of_storage);
690 * Erases all the elements. Note that this function only erases the
691 * elements, and that if the elements themselves are pointers, the
692 * pointed-to memory is not touched in any way. Managing the pointer is
693 * the user's responsibilty.
696 clear() { erase(begin(), end()); }
701 * Memory expansion handler. Uses the member allocation function to
702 * obtain @a n bytes of memory, and then copies [first,last) into it.
705 template<typename _ForwardIterator>
707 _M_allocate_and_copy(size_type __n,
708 _ForwardIterator __first, _ForwardIterator __last)
710 pointer __result = this->_M_allocate(__n);
713 std::uninitialized_copy(__first, __last, __result);
718 _M_deallocate(__result, __n);
719 __throw_exception_again;
724 // Internal constructor functions follow.
726 // Called by the range constructor to implement [23.1.1]/9
727 template<typename _Integer>
729 _M_initialize_dispatch(_Integer __n, _Integer __value, __true_type)
731 this->_M_start = _M_allocate(__n);
732 this->_M_end_of_storage = this->_M_start + __n;
733 this->_M_finish = std::uninitialized_fill_n(this->_M_start,
737 // Called by the range constructor to implement [23.1.1]/9
738 template<typename _InputIterator>
740 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
743 typedef typename iterator_traits<_InputIterator>::iterator_category
745 _M_range_initialize(__first, __last, _IterCategory());
748 // Called by the second initialize_dispatch above
749 template<typename _InputIterator>
751 _M_range_initialize(_InputIterator __first,
752 _InputIterator __last, input_iterator_tag)
754 for ( ; __first != __last; ++__first)
758 // Called by the second initialize_dispatch above
759 template<typename _ForwardIterator>
761 _M_range_initialize(_ForwardIterator __first,
762 _ForwardIterator __last, forward_iterator_tag)
764 size_type __n = std::distance(__first, __last);
765 this->_M_start = this->_M_allocate(__n);
766 this->_M_end_of_storage = this->_M_start + __n;
767 this->_M_finish = std::uninitialized_copy(__first, __last,
772 // Internal assign functions follow. The *_aux functions do the actual
773 // assignment work for the range versions.
775 // Called by the range assign to implement [23.1.1]/9
776 template<typename _Integer>
778 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
780 _M_fill_assign(static_cast<size_type>(__n),
781 static_cast<value_type>(__val));
784 // Called by the range assign to implement [23.1.1]/9
785 template<typename _InputIterator>
787 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
790 typedef typename iterator_traits<_InputIterator>::iterator_category
792 _M_assign_aux(__first, __last, _IterCategory());
795 // Called by the second assign_dispatch above
796 template<typename _InputIterator>
798 _M_assign_aux(_InputIterator __first, _InputIterator __last,
801 // Called by the second assign_dispatch above
802 template<typename _ForwardIterator>
804 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
805 forward_iterator_tag);
807 // Called by assign(n,t), and the range assign when it turns out
808 // to be the same thing.
810 _M_fill_assign(size_type __n, const value_type& __val);
813 // Internal insert functions follow.
815 // Called by the range insert to implement [23.1.1]/9
816 template<typename _Integer>
818 _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
821 _M_fill_insert(__pos, static_cast<size_type>(__n),
822 static_cast<value_type>(__val));
825 // Called by the range insert to implement [23.1.1]/9
826 template<typename _InputIterator>
828 _M_insert_dispatch(iterator __pos, _InputIterator __first,
829 _InputIterator __last, __false_type)
831 typedef typename iterator_traits<_InputIterator>::iterator_category
833 _M_range_insert(__pos, __first, __last, _IterCategory());
836 // Called by the second insert_dispatch above
837 template<typename _InputIterator>
839 _M_range_insert(iterator __pos, _InputIterator __first,
840 _InputIterator __last, input_iterator_tag);
842 // Called by the second insert_dispatch above
843 template<typename _ForwardIterator>
845 _M_range_insert(iterator __pos, _ForwardIterator __first,
846 _ForwardIterator __last, forward_iterator_tag);
848 // Called by insert(p,n,x), and the range insert when it turns out to be
851 _M_fill_insert(iterator __pos, size_type __n, const value_type& __x);
853 // Called by insert(p,x)
855 _M_insert_aux(iterator __position, const value_type& __x);
860 * @brief Vector equality comparison.
861 * @param x A %vector.
862 * @param y A %vector of the same type as @a x.
863 * @return True iff the size and elements of the vectors are equal.
865 * This is an equivalence relation. It is linear in the size of the
866 * vectors. Vectors are considered equivalent if their sizes are equal,
867 * and if corresponding elements compare equal.
869 template<typename _Tp, typename _Alloc>
871 operator==(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y)
873 return __x.size() == __y.size() &&
874 std::equal(__x.begin(), __x.end(), __y.begin());
878 * @brief Vector ordering relation.
879 * @param x A %vector.
880 * @param y A %vector of the same type as @a x.
881 * @return True iff @a x is lexicographically less than @a y.
883 * This is a total ordering relation. It is linear in the size of the
884 * vectors. The elements must be comparable with @c <.
886 * See std::lexicographical_compare() for how the determination is made.
888 template<typename _Tp, typename _Alloc>
890 operator<(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y)
892 return std::lexicographical_compare(__x.begin(), __x.end(),
893 __y.begin(), __y.end());
896 /// Based on operator==
897 template<typename _Tp, typename _Alloc>
899 operator!=(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y)
900 { return !(__x == __y); }
902 /// Based on operator<
903 template<typename _Tp, typename _Alloc>
905 operator>(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y)
906 { return __y < __x; }
908 /// Based on operator<
909 template<typename _Tp, typename _Alloc>
911 operator<=(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y)
912 { return !(__y < __x); }
914 /// Based on operator<
915 template<typename _Tp, typename _Alloc>
917 operator>=(const vector<_Tp,_Alloc>& __x, const vector<_Tp,_Alloc>& __y)
918 { return !(__x < __y); }
920 /// See std::vector::swap().
921 template<typename _Tp, typename _Alloc>
923 swap(vector<_Tp,_Alloc>& __x, vector<_Tp,_Alloc>& __y)
925 } // namespace __gnu_norm
927 #endif /* _VECTOR_H */