1 // Vector implementation -*- C++ -*-
3 // Copyright (C) 2001, 2002, 2003, 2004 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>
68 namespace _GLIBCXX_STD
72 * See bits/stl_deque.h's _Deque_base for an explanation.
75 template<typename _Tp, typename _Alloc>
83 _Tp* _M_end_of_storage;
84 _Vector_impl(_Alloc const& __a)
85 : _Alloc(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0)
90 typedef _Alloc allocator_type;
94 { return *static_cast<const _Alloc*>(&this->_M_impl); }
96 _Vector_base(const allocator_type& __a)
100 _Vector_base(size_t __n, const allocator_type& __a)
103 this->_M_impl._M_start = this->_M_allocate(__n);
104 this->_M_impl._M_finish = this->_M_impl._M_start;
105 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
109 { _M_deallocate(this->_M_impl._M_start, this->_M_impl._M_end_of_storage
110 - this->_M_impl._M_start); }
113 _Vector_impl _M_impl;
116 _M_allocate(size_t __n)
117 { return _M_impl.allocate(__n); }
120 _M_deallocate(_Tp* __p, size_t __n)
123 _M_impl.deallocate(__p, __n);
129 * @brief A standard container which offers fixed time access to
130 * individual elements in any order.
132 * @ingroup Containers
135 * Meets the requirements of a <a href="tables.html#65">container</a>, a
136 * <a href="tables.html#66">reversible container</a>, and a
137 * <a href="tables.html#67">sequence</a>, including the
138 * <a href="tables.html#68">optional sequence requirements</a> with the
139 * %exception of @c push_front and @c pop_front.
141 * In some terminology a %vector can be described as a dynamic
142 * C-style array, it offers fast and efficient access to individual
143 * elements in any order and saves the user from worrying about
144 * memory and size allocation. Subscripting ( @c [] ) access is
145 * also provided as with C-style arrays.
147 template<typename _Tp, typename _Alloc = allocator<_Tp> >
148 class vector : protected _Vector_base<_Tp, _Alloc>
150 // Concept requirements.
151 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
153 typedef _Vector_base<_Tp, _Alloc> _Base;
154 typedef vector<_Tp, _Alloc> vector_type;
157 typedef _Tp value_type;
158 typedef typename _Alloc::pointer pointer;
159 typedef typename _Alloc::const_pointer const_pointer;
160 typedef typename _Alloc::reference reference;
161 typedef typename _Alloc::const_reference const_reference;
162 typedef __gnu_cxx::__normal_iterator<pointer, vector_type> iterator;
163 typedef __gnu_cxx::__normal_iterator<const_pointer, vector_type>
165 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
166 typedef std::reverse_iterator<iterator> reverse_iterator;
167 typedef size_t size_type;
168 typedef ptrdiff_t difference_type;
169 typedef typename _Base::allocator_type allocator_type;
173 * These two functions and three data members are all from the
174 * base class. They should be pretty self-explanatory, as
175 * %vector uses a simple contiguous allocation scheme. @endif
177 using _Base::_M_allocate;
178 using _Base::_M_deallocate;
179 using _Base::_M_impl;
182 // [23.2.4.1] construct/copy/destroy
183 // (assign() and get_allocator() are also listed in this section)
185 * @brief Default constructor creates no elements.
188 vector(const allocator_type& __a = allocator_type())
193 * @brief Create a %vector with copies of an exemplar element.
194 * @param n The number of elements to initially create.
195 * @param value An element to copy.
197 * This constructor fills the %vector with @a n copies of @a value.
199 vector(size_type __n, const value_type& __value,
200 const allocator_type& __a = allocator_type())
203 std::uninitialized_fill_n(this->_M_impl._M_start, __n, __value);
204 this->_M_impl._M_finish = this->_M_impl._M_start + __n;
208 * @brief Create a %vector with default elements.
209 * @param n The number of elements to initially create.
211 * This constructor fills the %vector with @a n copies of a
212 * default-constructed element.
215 vector(size_type __n)
216 : _Base(__n, allocator_type())
218 std::uninitialized_fill_n(this->_M_impl._M_start, __n, value_type());
219 this->_M_impl._M_finish = this->_M_impl._M_start + __n;
223 * @brief %Vector copy constructor.
224 * @param x A %vector of identical element and allocator types.
226 * The newly-created %vector uses a copy of the allocation
227 * object used by @a x. All the elements of @a x are copied,
228 * but any extra memory in
229 * @a x (for fast expansion) will not be copied.
231 vector(const vector& __x)
232 : _Base(__x.size(), __x.get_allocator())
233 { this->_M_impl._M_finish = std::uninitialized_copy(__x.begin(),
239 * @brief Builds a %vector from a range.
240 * @param first An input iterator.
241 * @param last An input iterator.
243 * Create a %vector consisting of copies of the elements from
246 * If the iterators are forward, bidirectional, or
247 * random-access, then this will call the elements' copy
248 * constructor N times (where N is distance(first,last)) and do
249 * no memory reallocation. But if only input iterators are
250 * used, then this will do at most 2N calls to the copy
251 * constructor, and logN memory reallocations.
253 template<typename _InputIterator>
254 vector(_InputIterator __first, _InputIterator __last,
255 const allocator_type& __a = allocator_type())
258 // Check whether it's an integral type. If so, it's not an iterator.
259 typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
260 _M_initialize_dispatch(__first, __last, _Integral());
264 * The dtor only erases the elements, and note that if the
265 * elements themselves are pointers, the pointed-to memory is
266 * not touched in any way. Managing the pointer is the user's
270 { std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish); }
273 * @brief %Vector assignment operator.
274 * @param x A %vector of identical element and allocator types.
276 * All the elements of @a x are copied, but any extra memory in
277 * @a x (for fast expansion) will not be copied. Unlike the
278 * copy constructor, the allocator object is not copied.
281 operator=(const vector& __x);
284 * @brief Assigns a given value to a %vector.
285 * @param n Number of elements to be assigned.
286 * @param val Value to be assigned.
288 * This function fills a %vector with @a n copies of the given
289 * value. Note that the assignment completely changes the
290 * %vector and that the resulting %vector's size is the same as
291 * the number of elements assigned. Old data may be lost.
294 assign(size_type __n, const value_type& __val)
295 { _M_fill_assign(__n, __val); }
298 * @brief Assigns a range to a %vector.
299 * @param first An input iterator.
300 * @param last An input iterator.
302 * This function fills a %vector with copies of the elements in the
303 * range [first,last).
305 * Note that the assignment completely changes the %vector and
306 * that the resulting %vector's size is the same as the number
307 * of elements assigned. Old data may be lost.
309 template<typename _InputIterator>
311 assign(_InputIterator __first, _InputIterator __last)
313 // Check whether it's an integral type. If so, it's not an iterator.
314 typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
315 _M_assign_dispatch(__first, __last, _Integral());
318 /// Get a copy of the memory allocation object.
319 using _Base::get_allocator;
323 * Returns a read/write iterator that points to the first
324 * element in the %vector. Iteration is done in ordinary
329 { return iterator (this->_M_impl._M_start); }
332 * Returns a read-only (constant) iterator that points to the
333 * first element in the %vector. Iteration is done in ordinary
338 { return const_iterator (this->_M_impl._M_start); }
341 * Returns a read/write iterator that points one past the last
342 * element in the %vector. Iteration is done in ordinary
347 { return iterator (this->_M_impl._M_finish); }
350 * Returns a read-only (constant) iterator that points one past
351 * the last element in the %vector. Iteration is done in
352 * ordinary element order.
356 { return const_iterator (this->_M_impl._M_finish); }
359 * Returns a read/write reverse iterator that points to the
360 * last element in the %vector. Iteration is done in reverse
365 { return reverse_iterator(end()); }
368 * Returns a read-only (constant) reverse iterator that points
369 * to the last element in the %vector. Iteration is done in
370 * reverse element order.
372 const_reverse_iterator
374 { return const_reverse_iterator(end()); }
377 * Returns a read/write reverse iterator that points to one
378 * before the first element in the %vector. Iteration is done
379 * in reverse element order.
383 { return reverse_iterator(begin()); }
386 * Returns a read-only (constant) reverse iterator that points
387 * to one before the first element in the %vector. Iteration
388 * is done in reverse element order.
390 const_reverse_iterator
392 { return const_reverse_iterator(begin()); }
394 // [23.2.4.2] capacity
395 /** Returns the number of elements in the %vector. */
398 { return size_type(end() - begin()); }
400 /** Returns the size() of the largest possible %vector. */
403 { return size_type(-1) / sizeof(value_type); }
406 * @brief Resizes the %vector to the specified number of elements.
407 * @param new_size Number of elements the %vector should contain.
408 * @param x Data with which new elements should be populated.
410 * This function will %resize the %vector to the specified
411 * number of elements. If the number is smaller than the
412 * %vector's current size the %vector is truncated, otherwise
413 * the %vector is extended and new elements are populated with
417 resize(size_type __new_size, const value_type& __x)
419 if (__new_size < size())
420 erase(begin() + __new_size, end());
422 insert(end(), __new_size - size(), __x);
426 * @brief Resizes the %vector to the specified number of elements.
427 * @param new_size Number of elements the %vector should contain.
429 * This function will resize the %vector to the specified
430 * number of elements. If the number is smaller than the
431 * %vector's current size the %vector is truncated, otherwise
432 * the %vector is extended and new elements are
433 * default-constructed.
436 resize(size_type __new_size)
437 { resize(__new_size, value_type()); }
440 * Returns the total number of elements that the %vector can
441 * hold before needing to allocate more memory.
445 { return size_type(const_iterator(this->_M_impl._M_end_of_storage)
449 * Returns true if the %vector is empty. (Thus begin() would
454 { return begin() == end(); }
457 * @brief Attempt to preallocate enough memory for specified number of
459 * @param n Number of elements required.
460 * @throw std::length_error If @a n exceeds @c max_size().
462 * This function attempts to reserve enough memory for the
463 * %vector to hold the specified number of elements. If the
464 * number requested is more than max_size(), length_error is
467 * The advantage of this function is that if optimal code is a
468 * necessity and the user can determine the number of elements
469 * that will be required, the user can reserve the memory in
470 * %advance, and thus prevent a possible reallocation of memory
471 * and copying of %vector data.
474 reserve(size_type __n);
478 * @brief Subscript access to the data contained in the %vector.
479 * @param n The index of the element for which data should be
481 * @return Read/write reference to data.
483 * This operator allows for easy, array-style, data access.
484 * Note that data access with this operator is unchecked and
485 * out_of_range lookups are not defined. (For checked lookups
489 operator[](size_type __n)
490 { return *(begin() + __n); }
493 * @brief Subscript access to the data contained in the %vector.
494 * @param n The index of the element for which data should be
496 * @return Read-only (constant) reference to data.
498 * This operator allows for easy, array-style, data access.
499 * Note that data access with this operator is unchecked and
500 * out_of_range lookups are not defined. (For checked lookups
504 operator[](size_type __n) const
505 { return *(begin() + __n); }
508 /// @if maint Safety check used only from at(). @endif
510 _M_range_check(size_type __n) const
512 if (__n >= this->size())
513 __throw_out_of_range(__N("vector::_M_range_check"));
518 * @brief Provides access to the data contained in the %vector.
519 * @param n The index of the element for which data should be
521 * @return Read/write reference to data.
522 * @throw std::out_of_range If @a n is an invalid index.
524 * This function provides for safer data access. The parameter
525 * is first checked that it is in the range of the vector. The
526 * function throws out_of_range if the check fails.
536 * @brief Provides access to the data contained in the %vector.
537 * @param n The index of the element for which data should be
539 * @return Read-only (constant) reference to data.
540 * @throw std::out_of_range If @a n is an invalid index.
542 * This function provides for safer data access. The parameter
543 * is first checked that it is in the range of the vector. The
544 * function throws out_of_range if the check fails.
547 at(size_type __n) const
554 * Returns a read/write reference to the data at the first
555 * element of the %vector.
562 * Returns a read-only (constant) reference to the data at the first
563 * element of the %vector.
570 * Returns a read/write reference to the data at the last
571 * element of the %vector.
575 { return *(end() - 1); }
578 * Returns a read-only (constant) reference to the data at the
579 * last element of the %vector.
583 { return *(end() - 1); }
585 // [23.2.4.3] modifiers
587 * @brief Add data to the end of the %vector.
588 * @param x Data to be added.
590 * This is a typical stack operation. The function creates an
591 * element at the end of the %vector and assigns the given data
592 * to it. Due to the nature of a %vector this operation can be
593 * done in constant time if the %vector has preallocated space
597 push_back(const value_type& __x)
599 if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
601 std::_Construct(this->_M_impl._M_finish, __x);
602 ++this->_M_impl._M_finish;
605 _M_insert_aux(end(), __x);
609 * @brief Removes last element.
611 * This is a typical stack operation. It shrinks the %vector by one.
613 * Note that no data is returned, and if the last element's
614 * data is needed, it should be retrieved before pop_back() is
620 --this->_M_impl._M_finish;
621 std::_Destroy(this->_M_impl._M_finish);
625 * @brief Inserts given value into %vector before specified iterator.
626 * @param position An iterator into the %vector.
627 * @param x Data to be inserted.
628 * @return An iterator that points to the inserted data.
630 * This function will insert a copy of the given value before
631 * the specified location. Note that this kind of operation
632 * could be expensive for a %vector and if it is frequently
633 * used the user should consider using std::list.
636 insert(iterator __position, const value_type& __x);
639 * @brief Inserts a number of copies of given data into the %vector.
640 * @param position An iterator into the %vector.
641 * @param n Number of elements to be inserted.
642 * @param x Data to be inserted.
644 * This function will insert a specified number of copies of
645 * the given data before the location specified by @a position.
647 * Note that this kind of operation could be expensive for a
648 * %vector and if it is frequently used the user should
649 * consider using std::list.
652 insert(iterator __position, size_type __n, const value_type& __x)
653 { _M_fill_insert(__position, __n, __x); }
656 * @brief Inserts a range into the %vector.
657 * @param position An iterator into the %vector.
658 * @param first An input iterator.
659 * @param last An input iterator.
661 * This function will insert copies of the data in the range
662 * [first,last) into the %vector before the location specified
665 * Note that this kind of operation could be expensive for a
666 * %vector and if it is frequently used the user should
667 * consider using std::list.
669 template<typename _InputIterator>
671 insert(iterator __position, _InputIterator __first,
672 _InputIterator __last)
674 // Check whether it's an integral type. If so, it's not an iterator.
675 typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
676 _M_insert_dispatch(__position, __first, __last, _Integral());
680 * @brief Remove element at given position.
681 * @param position Iterator pointing to element to be erased.
682 * @return An iterator pointing to the next element (or end()).
684 * This function will erase the element at the given position and thus
685 * shorten the %vector by one.
687 * Note This operation could be expensive and if it is
688 * frequently used the user should consider using std::list.
689 * The user is also cautioned that this function only erases
690 * the element, and that if the element is itself a pointer,
691 * the pointed-to memory is not touched in any way. Managing
692 * the pointer is the user's responsibilty.
695 erase(iterator __position);
698 * @brief Remove a range of elements.
699 * @param first Iterator pointing to the first element to be erased.
700 * @param last Iterator pointing to one past the last element to be
702 * @return An iterator pointing to the element pointed to by @a last
703 * prior to erasing (or end()).
705 * This function will erase the elements in the range [first,last) and
706 * shorten the %vector accordingly.
708 * Note This operation could be expensive and if it is
709 * frequently used the user should consider using std::list.
710 * The user is also cautioned that this function only erases
711 * the elements, and that if the elements themselves are
712 * pointers, the pointed-to memory is not touched in any way.
713 * Managing the pointer is the user's responsibilty.
716 erase(iterator __first, iterator __last);
719 * @brief Swaps data with another %vector.
720 * @param x A %vector of the same element and allocator types.
722 * This exchanges the elements between two vectors in constant time.
723 * (Three pointers, so it should be quite fast.)
724 * Note that the global std::swap() function is specialized such that
725 * std::swap(v1,v2) will feed to this function.
730 std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
731 std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);
732 std::swap(this->_M_impl._M_end_of_storage,
733 __x._M_impl._M_end_of_storage);
737 * Erases all the elements. Note that this function only erases the
738 * elements, and that if the elements themselves are pointers, the
739 * pointed-to memory is not touched in any way. Managing the pointer is
740 * the user's responsibilty.
744 { erase(begin(), end()); }
749 * Memory expansion handler. Uses the member allocation function to
750 * obtain @a n bytes of memory, and then copies [first,last) into it.
753 template<typename _ForwardIterator>
755 _M_allocate_and_copy(size_type __n,
756 _ForwardIterator __first, _ForwardIterator __last)
758 pointer __result = this->_M_allocate(__n);
761 std::uninitialized_copy(__first, __last, __result);
766 _M_deallocate(__result, __n);
767 __throw_exception_again;
772 // Internal constructor functions follow.
774 // Called by the range constructor to implement [23.1.1]/9
775 template<typename _Integer>
777 _M_initialize_dispatch(_Integer __n, _Integer __value, __true_type)
779 this->_M_impl._M_start = _M_allocate(__n);
780 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
781 std::uninitialized_fill_n(this->_M_impl._M_start, __n, __value);
782 this->_M_impl._M_finish = this->_M_impl._M_end_of_storage;
785 // Called by the range constructor to implement [23.1.1]/9
786 template<typename _InputIterator>
788 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
791 typedef typename iterator_traits<_InputIterator>::iterator_category
793 _M_range_initialize(__first, __last, _IterCategory());
796 // Called by the second initialize_dispatch above
797 template<typename _InputIterator>
799 _M_range_initialize(_InputIterator __first,
800 _InputIterator __last, input_iterator_tag)
802 for (; __first != __last; ++__first)
806 // Called by the second initialize_dispatch above
807 template<typename _ForwardIterator>
809 _M_range_initialize(_ForwardIterator __first,
810 _ForwardIterator __last, forward_iterator_tag)
812 const size_type __n = std::distance(__first, __last);
813 this->_M_impl._M_start = this->_M_allocate(__n);
814 this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
815 this->_M_impl._M_finish = std::uninitialized_copy(__first, __last,
821 // Internal assign functions follow. The *_aux functions do the actual
822 // assignment work for the range versions.
824 // Called by the range assign to implement [23.1.1]/9
825 template<typename _Integer>
827 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
829 _M_fill_assign(static_cast<size_type>(__n),
830 static_cast<value_type>(__val));
833 // Called by the range assign to implement [23.1.1]/9
834 template<typename _InputIterator>
836 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
839 typedef typename iterator_traits<_InputIterator>::iterator_category
841 _M_assign_aux(__first, __last, _IterCategory());
844 // Called by the second assign_dispatch above
845 template<typename _InputIterator>
847 _M_assign_aux(_InputIterator __first, _InputIterator __last,
850 // Called by the second assign_dispatch above
851 template<typename _ForwardIterator>
853 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
854 forward_iterator_tag);
856 // Called by assign(n,t), and the range assign when it turns out
857 // to be the same thing.
859 _M_fill_assign(size_type __n, const value_type& __val);
862 // Internal insert functions follow.
864 // Called by the range insert to implement [23.1.1]/9
865 template<typename _Integer>
867 _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
870 _M_fill_insert(__pos, static_cast<size_type>(__n),
871 static_cast<value_type>(__val));
874 // Called by the range insert to implement [23.1.1]/9
875 template<typename _InputIterator>
877 _M_insert_dispatch(iterator __pos, _InputIterator __first,
878 _InputIterator __last, __false_type)
880 typedef typename iterator_traits<_InputIterator>::iterator_category
882 _M_range_insert(__pos, __first, __last, _IterCategory());
885 // Called by the second insert_dispatch above
886 template<typename _InputIterator>
888 _M_range_insert(iterator __pos, _InputIterator __first,
889 _InputIterator __last, input_iterator_tag);
891 // Called by the second insert_dispatch above
892 template<typename _ForwardIterator>
894 _M_range_insert(iterator __pos, _ForwardIterator __first,
895 _ForwardIterator __last, forward_iterator_tag);
897 // Called by insert(p,n,x), and the range insert when it turns out to be
900 _M_fill_insert(iterator __pos, size_type __n, const value_type& __x);
902 // Called by insert(p,x)
904 _M_insert_aux(iterator __position, const value_type& __x);
909 * @brief Vector equality comparison.
910 * @param x A %vector.
911 * @param y A %vector of the same type as @a x.
912 * @return True iff the size and elements of the vectors are equal.
914 * This is an equivalence relation. It is linear in the size of the
915 * vectors. Vectors are considered equivalent if their sizes are equal,
916 * and if corresponding elements compare equal.
918 template<typename _Tp, typename _Alloc>
920 operator==(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
921 { return (__x.size() == __y.size()
922 && std::equal(__x.begin(), __x.end(), __y.begin())); }
925 * @brief Vector ordering relation.
926 * @param x A %vector.
927 * @param y A %vector of the same type as @a x.
928 * @return True iff @a x is lexicographically less than @a y.
930 * This is a total ordering relation. It is linear in the size of the
931 * vectors. The elements must be comparable with @c <.
933 * See std::lexicographical_compare() for how the determination is made.
935 template<typename _Tp, typename _Alloc>
937 operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
938 { return std::lexicographical_compare(__x.begin(), __x.end(),
939 __y.begin(), __y.end()); }
941 /// Based on operator==
942 template<typename _Tp, typename _Alloc>
944 operator!=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
945 { return !(__x == __y); }
947 /// Based on operator<
948 template<typename _Tp, typename _Alloc>
950 operator>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
951 { return __y < __x; }
953 /// Based on operator<
954 template<typename _Tp, typename _Alloc>
956 operator<=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
957 { return !(__y < __x); }
959 /// Based on operator<
960 template<typename _Tp, typename _Alloc>
962 operator>=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
963 { return !(__x < __y); }
965 /// See std::vector::swap().
966 template<typename _Tp, typename _Alloc>
968 swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y)
972 #endif /* _VECTOR_H */