[multiple changes]

2007-10-04  Paolo Carlini  <pcarlini@suse.de>

	* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
	Adjust dg-error line number.
	* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
	Likewise.
	* testsuite/23_containers/vector/requirements/dr438/
	constructor_1_neg.cc: Likewise.
	* testsuite/23_containers/vector/requirements/dr438/
	constructor_2_neg.cc: Likewise.
	* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc:
	Adjust dg-error line number.
	* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc:
	Likewise.
	* testsuite/23_containers/deque/requirements/dr438/
	constructor_1_neg.cc: Likewise.
	* testsuite/23_containers/deque/requirements/dr438/
	constructor_2_neg.cc: Likewise.
	* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
	Adjust dg-error line number.
	* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
	Likewise.
	* testsuite/23_containers/list/requirements/dr438/
	constructor_1_neg.cc: Likewise.
	* testsuite/23_containers/list/requirements/dr438/
	constructor_2_neg.cc: Likewise.

2007-10-04  Chris Jefferson  <chris@bubblescope.net>
	    Paolo Carlini  <pcarlini@suse.de>

	* include/bits/stl_list.h (list<>::list(list&&),
	list<>::operator=(list&&)): Add.
	(list<>::swap): Adjust.
	(swap(list&&, list& __y), swap(list&, list&& __y)): Add.
	* include/bits/stl_vector.h (vector<>::vector(vector&&),
	vector<>::operator=(vector&&)): Add.
	(vector<>::swap): Adjust.
	(swap(vector&&, vector& __y), swap(vector&, vector&& __y)): Add.
	* include/bits/stl_bvector.h (vector<>::vector(vector&&),
	vector<>::operator=(vector&&)): Add.
	(vector<>::swap): Adjust.
	* include/bits/stl_deque.h (deque<>::deque(deque&&),
	deque<>::operator=(deque&&)): Add.
	(deque<>::swap): Adjust.
	(swap(deque&&, deque& __y), swap(deque&, deque&& __y)): Add.
	* include/bits/stl_set.h (set<>::set(set&&),
	set<>::operator=(set&&)): Add.
	(set<>::swap): Adjust.
	(swap(set&&, set& __y), swap(set&, set&& __y)): Add.
	* include/bits/stl_map.h (map<>::map(map&&),
	map<>::operator=(map&&)): Add.
	(map<>::swap): Adjust.
	(swap(map&&, map& __y), swap(map&, map&& __y)): Add.
	* include/bits/stl_multiset.h (multiset<>::multiset(multiset&&),
	multiset<>::operator=(multiset&&)): Add.
	(smultiet<>::swap): Adjust.
	(swap(multiset&&, multiset& __y),
	swap(multiset&, multiset&& __y)): Add.
	* include/bits/stl_multimap.h (multimap<>::multimap(multimap&&),
	multimap<>::operator=(multimap&&)): Add.
	(multimap<>::swap): Adjust.
	(swap(multimap&&, multimap& __y),
	swap(multimap&, multimap&& __y)): Add.

2007-10-04  Paolo Carlini  <pcarlini@suse.de>

	Avoid copying some allocator objects.
	* include/bits/stl_list.h (_List_impl::_List_impl(),
	_List_base::_List_base(), list<>::list()): Add.
	* include/bits/stl_vector.h  (_Vector_impl::_Vector_impl(),
	_Vector_base::_Vector_base(), vector<>::vector()): Add.
	* include/bits/stl_bvector.h (_Bvector_impl::_Bvector_impl(),
	_Bvector_base::_Bvector_base(), vector<>::vector()): Add.
	* include/bits/stl_deque.h  (_Deque_impl::_Deque_impl(),
	_Deque_base::_Deque_base(), deque<>::deque()): Add.
	* include/bits/stl_tree.h (_Rb_tree_impl<>::_Rb_tree_impl(),
	_Rb_tree_impl<>::_M_initialize): Add.
	(_Rb_tree<>::_Rb_tree(const _Compare&, const allocator_type&),
	_Rb_tree(const _Rb_tree&)): Adjust.
	* include/bits/stl_set.h (set<>::set(),
	set(_InputIterator, _InputIterator)): Use _M_t default constructor. 
	* include/bits/stl_map.h (map<>::map(), set(_InputIterator,
	_InputIterator)): Use _M_t default constructor. 
	* include/bits/stl_multiset.h (multiset<>::multiset(),
	multiset(_InputIterator, _InputIterator)): Use _M_t default
	constructor. 
	* include/bits/stl_multimap.h (multimap<>::multimap(),
	multimap(_InputIterator, _InputIterator)): Use _M_t default
	constructor.

From-SVN: r129013
This commit is contained in:
Paolo Carlini 2007-10-04 15:12:34 +00:00
parent 187de1ed2b
commit 78b36b70be
22 changed files with 685 additions and 159 deletions

View File

@ -1,3 +1,93 @@
2007-10-04 Paolo Carlini <pcarlini@suse.de>
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
Adjust dg-error line number.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc:
Adjust dg-error line number.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
Adjust dg-error line number.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Likewise.
2007-10-04 Chris Jefferson <chris@bubblescope.net>
Paolo Carlini <pcarlini@suse.de>
* include/bits/stl_list.h (list<>::list(list&&),
list<>::operator=(list&&)): Add.
(list<>::swap): Adjust.
(swap(list&&, list& __y), swap(list&, list&& __y)): Add.
* include/bits/stl_vector.h (vector<>::vector(vector&&),
vector<>::operator=(vector&&)): Add.
(vector<>::swap): Adjust.
(swap(vector&&, vector& __y), swap(vector&, vector&& __y)): Add.
* include/bits/stl_bvector.h (vector<>::vector(vector&&),
vector<>::operator=(vector&&)): Add.
(vector<>::swap): Adjust.
* include/bits/stl_deque.h (deque<>::deque(deque&&),
deque<>::operator=(deque&&)): Add.
(deque<>::swap): Adjust.
(swap(deque&&, deque& __y), swap(deque&, deque&& __y)): Add.
* include/bits/stl_set.h (set<>::set(set&&),
set<>::operator=(set&&)): Add.
(set<>::swap): Adjust.
(swap(set&&, set& __y), swap(set&, set&& __y)): Add.
* include/bits/stl_map.h (map<>::map(map&&),
map<>::operator=(map&&)): Add.
(map<>::swap): Adjust.
(swap(map&&, map& __y), swap(map&, map&& __y)): Add.
* include/bits/stl_multiset.h (multiset<>::multiset(multiset&&),
multiset<>::operator=(multiset&&)): Add.
(smultiet<>::swap): Adjust.
(swap(multiset&&, multiset& __y),
swap(multiset&, multiset&& __y)): Add.
* include/bits/stl_multimap.h (multimap<>::multimap(multimap&&),
multimap<>::operator=(multimap&&)): Add.
(multimap<>::swap): Adjust.
(swap(multimap&&, multimap& __y),
swap(multimap&, multimap&& __y)): Add.
2007-10-04 Paolo Carlini <pcarlini@suse.de>
Avoid copying some allocator objects.
* include/bits/stl_list.h (_List_impl::_List_impl(),
_List_base::_List_base(), list<>::list()): Add.
* include/bits/stl_vector.h (_Vector_impl::_Vector_impl(),
_Vector_base::_Vector_base(), vector<>::vector()): Add.
* include/bits/stl_bvector.h (_Bvector_impl::_Bvector_impl(),
_Bvector_base::_Bvector_base(), vector<>::vector()): Add.
* include/bits/stl_deque.h (_Deque_impl::_Deque_impl(),
_Deque_base::_Deque_base(), deque<>::deque()): Add.
* include/bits/stl_tree.h (_Rb_tree_impl<>::_Rb_tree_impl(),
_Rb_tree_impl<>::_M_initialize): Add.
(_Rb_tree<>::_Rb_tree(const _Compare&, const allocator_type&),
_Rb_tree(const _Rb_tree&)): Adjust.
* include/bits/stl_set.h (set<>::set(),
set(_InputIterator, _InputIterator)): Use _M_t default constructor.
* include/bits/stl_map.h (map<>::map(), set(_InputIterator,
_InputIterator)): Use _M_t default constructor.
* include/bits/stl_multiset.h (multiset<>::multiset(),
multiset(_InputIterator, _InputIterator)): Use _M_t default
constructor.
* include/bits/stl_multimap.h (multimap<>::multimap(),
multimap(_InputIterator, _InputIterator)): Use _M_t default
constructor.
2007-10-03 Chris Jefferson <chris@bubblescope.net> 2007-10-03 Chris Jefferson <chris@bubblescope.net>
Benjamin Kosnik <bkoz@redhat.com> Benjamin Kosnik <bkoz@redhat.com>

View File

@ -385,6 +385,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
_Bit_iterator _M_start; _Bit_iterator _M_start;
_Bit_iterator _M_finish; _Bit_iterator _M_finish;
_Bit_type* _M_end_of_storage; _Bit_type* _M_end_of_storage;
_Bvector_impl()
: _Bit_alloc_type(), _M_start(), _M_finish(), _M_end_of_storage(0)
{ }
_Bvector_impl(const _Bit_alloc_type& __a) _Bvector_impl(const _Bit_alloc_type& __a)
: _Bit_alloc_type(__a), _M_start(), _M_finish(), _M_end_of_storage(0) : _Bit_alloc_type(__a), _M_start(), _M_finish(), _M_end_of_storage(0)
{ } { }
@ -405,7 +410,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
get_allocator() const get_allocator() const
{ return allocator_type(_M_get_Bit_allocator()); } { return allocator_type(_M_get_Bit_allocator()); }
_Bvector_base(const allocator_type& __a) : _M_impl(__a) { } _Bvector_base()
: _M_impl() { }
_Bvector_base(const allocator_type& __a)
: _M_impl(__a) { }
~_Bvector_base() ~_Bvector_base()
{ this->_M_deallocate(); } { this->_M_deallocate(); }
@ -480,8 +489,11 @@ template<typename _Alloc>
using _Base::_M_get_Bit_allocator; using _Base::_M_get_Bit_allocator;
public: public:
vector()
: _Base() { }
explicit explicit
vector(const allocator_type& __a = allocator_type()) vector(const allocator_type& __a)
: _Base(__a) { } : _Base(__a) { }
explicit explicit
@ -501,6 +513,12 @@ template<typename _Alloc>
_M_copy_aligned(__x.begin(), __x.end(), this->_M_impl._M_start); _M_copy_aligned(__x.begin(), __x.end(), this->_M_impl._M_start);
} }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
vector(vector&& __x)
: _Base(__x._M_get_Bit_allocator())
{ this->swap(__x); }
#endif
template<typename _InputIterator> template<typename _InputIterator>
vector(_InputIterator __first, _InputIterator __last, vector(_InputIterator __first, _InputIterator __last,
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
@ -527,6 +545,15 @@ template<typename _Alloc>
return *this; return *this;
} }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
vector&
operator=(vector&& __x)
{
this->swap(__x);
return *this;
}
#endif
// assign(), a generalized assignment member function. Two // assign(), a generalized assignment member function. Two
// versions: one that takes a count, and one that takes a range. // versions: one that takes a count, and one that takes a range.
// The range version is a member template, so we dispatch on whether // The range version is a member template, so we dispatch on whether
@ -681,7 +708,11 @@ template<typename _Alloc>
} }
void void
swap(vector<bool, _Alloc>& __x) #ifdef __GXX_EXPERIMENTAL_CXX0X__
swap(vector&& __x)
#else
swap(vector& __x)
#endif
{ {
std::swap(this->_M_impl._M_start, __x._M_impl._M_start); std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish); std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);

View File

@ -123,13 +123,14 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
_Deque_iterator(_Tp* __x, _Map_pointer __y) _Deque_iterator(_Tp* __x, _Map_pointer __y)
: _M_cur(__x), _M_first(*__y), : _M_cur(__x), _M_first(*__y),
_M_last(*__y + _S_buffer_size()), _M_node(__y) {} _M_last(*__y + _S_buffer_size()), _M_node(__y) { }
_Deque_iterator() : _M_cur(0), _M_first(0), _M_last(0), _M_node(0) {} _Deque_iterator()
: _M_cur(0), _M_first(0), _M_last(0), _M_node(0) { }
_Deque_iterator(const iterator& __x) _Deque_iterator(const iterator& __x)
: _M_cur(__x._M_cur), _M_first(__x._M_first), : _M_cur(__x._M_cur), _M_first(__x._M_first),
_M_last(__x._M_last), _M_node(__x._M_node) {} _M_last(__x._M_last), _M_node(__x._M_node) { }
reference reference
operator*() const operator*() const
@ -380,6 +381,10 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
typedef _Deque_iterator<_Tp, _Tp&, _Tp*> iterator; typedef _Deque_iterator<_Tp, _Tp&, _Tp*> iterator;
typedef _Deque_iterator<_Tp, const _Tp&, const _Tp*> const_iterator; typedef _Deque_iterator<_Tp, const _Tp&, const _Tp*> const_iterator;
_Deque_base()
: _M_impl()
{ _M_initialize_map(0); }
_Deque_base(const allocator_type& __a, size_t __num_elements) _Deque_base(const allocator_type& __a, size_t __num_elements)
: _M_impl(__a) : _M_impl(__a)
{ _M_initialize_map(__num_elements); } { _M_initialize_map(__num_elements); }
@ -406,6 +411,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
iterator _M_start; iterator _M_start;
iterator _M_finish; iterator _M_finish;
_Deque_impl()
: _Tp_alloc_type(), _M_map(0), _M_map_size(0),
_M_start(), _M_finish()
{ }
_Deque_impl(const _Tp_alloc_type& __a) _Deque_impl(const _Tp_alloc_type& __a)
: _Tp_alloc_type(__a), _M_map(0), _M_map_size(0), : _Tp_alloc_type(__a), _M_map(0), _M_map_size(0),
_M_start(), _M_finish() _M_start(), _M_finish()
@ -679,14 +689,22 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
/** /**
* @brief Default constructor creates no elements. * @brief Default constructor creates no elements.
*/ */
explicit deque()
deque(const allocator_type& __a = allocator_type()) : _Base() { }
: _Base(__a, 0) {}
/** /**
* @brief Create a %deque with copies of an exemplar element. * @brief Creates a %deque with no elements.
* @param a An allocator object.
*/
explicit
deque(const allocator_type& __a)
: _Base(__a, 0) { }
/**
* @brief Creates a %deque with copies of an exemplar element.
* @param n The number of elements to initially create. * @param n The number of elements to initially create.
* @param value An element to copy. * @param value An element to copy.
* @param a An allocator.
* *
* This constructor fills the %deque with @a n copies of @a value. * This constructor fills the %deque with @a n copies of @a value.
*/ */
@ -709,10 +727,24 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
this->_M_impl._M_start, this->_M_impl._M_start,
_M_get_Tp_allocator()); } _M_get_Tp_allocator()); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/**
* @brief %Deque move constructor.
* @param x A %deque of identical element and allocator types.
*
* The newly-created %deque contains the exact contents of @a x.
* The contents of @a x are a valid, but unspecified %deque.
*/
deque(deque&& __x)
: _Base(__x._M_get_Tp_allocator(), 0)
{ this->swap(__x); }
#endif
/** /**
* @brief Builds a %deque from a range. * @brief Builds a %deque from a range.
* @param first An input iterator. * @param first An input iterator.
* @param last An input iterator. * @param last An input iterator.
* @param a An allocator object.
* *
* Create a %deque consisting of copies of the elements from [first, * Create a %deque consisting of copies of the elements from [first,
* last). * last).
@ -751,6 +783,22 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
deque& deque&
operator=(const deque& __x); operator=(const deque& __x);
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/**
* @brief %Deque move assignment operator.
* @param x A %deque of identical element and allocator types.
*
* The contents of @a x are moved into this deque (without copying).
* @a x is a valid, but unspecified %deque.
*/
deque&
operator=(deque&& __x)
{
this->swap(__x);
return *this;
}
#endif
/** /**
* @brief Assigns a given value to a %deque. * @brief Assigns a given value to a %deque.
* @param n Number of elements to be assigned. * @param n Number of elements to be assigned.
@ -1194,7 +1242,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* std::swap(d1,d2) will feed to this function. * std::swap(d1,d2) will feed to this function.
*/ */
void void
#ifdef __GXX_EXPERIMENTAL_CXX0X__
swap(deque&& __x)
#else
swap(deque& __x) swap(deque& __x)
#endif
{ {
std::swap(this->_M_impl._M_start, __x._M_impl._M_start); std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish); std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);
@ -1598,6 +1650,18 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y) swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y)
{ __x.swap(__y); } { __x.swap(__y); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Tp, typename _Alloc>
inline void
swap(deque<_Tp,_Alloc>&& __x, deque<_Tp,_Alloc>& __y)
{ __x.swap(__y); }
template<typename _Tp, typename _Alloc>
inline void
swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>&& __y)
{ __x.swap(__y); }
#endif
_GLIBCXX_END_NESTED_NAMESPACE _GLIBCXX_END_NESTED_NAMESPACE
#endif /* _STL_DEQUE_H */ #endif /* _STL_DEQUE_H */

View File

@ -305,6 +305,10 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
{ {
_List_node_base _M_node; _List_node_base _M_node;
_List_impl()
: _Node_alloc_type(), _M_node()
{ }
_List_impl(const _Node_alloc_type& __a) _List_impl(const _Node_alloc_type& __a)
: _Node_alloc_type(__a), _M_node() : _Node_alloc_type(__a), _M_node()
{ } { }
@ -339,6 +343,10 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
get_allocator() const get_allocator() const
{ return allocator_type(_M_get_Node_allocator()); } { return allocator_type(_M_get_Node_allocator()); }
_List_base()
: _M_impl()
{ _M_init(); }
_List_base(const allocator_type& __a) _List_base(const allocator_type& __a)
: _M_impl(__a) : _M_impl(__a)
{ _M_init(); } { _M_init(); }
@ -468,14 +476,22 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
/** /**
* @brief Default constructor creates no elements. * @brief Default constructor creates no elements.
*/ */
list()
: _Base() { }
/**
* @brief Creates a %list with no elements.
* @param a An allocator object.
*/
explicit explicit
list(const allocator_type& __a = allocator_type()) list(const allocator_type& __a)
: _Base(__a) { } : _Base(__a) { }
/** /**
* @brief Create a %list with copies of an exemplar element. * @brief Creates a %list with copies of an exemplar element.
* @param n The number of elements to initially create. * @param n The number of elements to initially create.
* @param value An element to copy. * @param value An element to copy.
* @param a An allocator object.
* *
* This constructor fills the %list with @a n copies of @a value. * This constructor fills the %list with @a n copies of @a value.
*/ */
@ -496,10 +512,24 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
: _Base(__x._M_get_Node_allocator()) : _Base(__x._M_get_Node_allocator())
{ _M_initialize_dispatch(__x.begin(), __x.end(), __false_type()); } { _M_initialize_dispatch(__x.begin(), __x.end(), __false_type()); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/**
* @brief %List move constructor.
* @param x A %list of identical element and allocator types.
*
* The newly-created %list contains the exact contents of @a x.
* The contents of @a x are a valid, but unspecified %list.
*/
list(list&& __x)
: _Base(__x._M_get_Node_allocator())
{ this->swap(__x); }
#endif
/** /**
* @brief Builds a %list from a range. * @brief Builds a %list from a range.
* @param first An input iterator. * @param first An input iterator.
* @param last An input iterator. * @param last An input iterator.
* @param a An allocator object.
* *
* Create a %list consisting of copies of the elements from * Create a %list consisting of copies of the elements from
* [@a first,@a last). This is linear in N (where N is * [@a first,@a last). This is linear in N (where N is
@ -533,6 +563,22 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
list& list&
operator=(const list& __x); operator=(const list& __x);
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/**
* @brief %List move assignment operator.
* @param x A %list of identical element and allocator types.
*
* The contents of @a x are moved into this %list (without copying).
* @a x is a valid, but unspecified %list
*/
list&
operator=(list&& __x)
{
this->swap(__x);
return *this;
}
#endif
/** /**
* @brief Assigns a given value to a %list. * @brief Assigns a given value to a %list.
* @param n Number of elements to be assigned. * @param n Number of elements to be assigned.
@ -887,7 +933,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* function. * function.
*/ */
void void
#ifdef __GXX_EXPERIMENTAL_CXX0X__
swap(list&& __x)
#else
swap(list& __x) swap(list& __x)
#endif
{ {
_List_node_base::swap(this->_M_impl._M_node, __x._M_impl._M_node); _List_node_base::swap(this->_M_impl._M_node, __x._M_impl._M_node);
@ -1256,7 +1306,18 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y) swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y)
{ __x.swap(__y); } { __x.swap(__y); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Tp, typename _Alloc>
inline void
swap(list<_Tp, _Alloc>&& __x, list<_Tp, _Alloc>& __y)
{ __x.swap(__y); }
template<typename _Tp, typename _Alloc>
inline void
swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>&& __y)
{ __x.swap(__y); }
#endif
_GLIBCXX_END_NESTED_NAMESPACE _GLIBCXX_END_NESTED_NAMESPACE
#endif /* _STL_LIST_H */ #endif /* _STL_LIST_H */

View File

@ -155,26 +155,42 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* @brief Default constructor creates no elements. * @brief Default constructor creates no elements.
*/ */
map() map()
: _M_t(_Compare(), allocator_type()) { } : _M_t() { }
// for some reason this was made a separate function
/** /**
* @brief Default constructor creates no elements. * @brief Creates a %map with no elements.
* @param comp A comparison object.
* @param a An allocator object.
*/ */
explicit explicit
map(const _Compare& __comp, const allocator_type& __a = allocator_type()) map(const _Compare& __comp,
const allocator_type& __a = allocator_type())
: _M_t(__comp, __a) { } : _M_t(__comp, __a) { }
/** /**
* @brief Map copy constructor. * @brief %Map copy constructor.
* @param x A %map of identical element and allocator types. * @param x A %map of identical element and allocator types.
* *
* The newly-created %map uses a copy of the allocation object used * The newly-created %map uses a copy of the allocation object
* by @a x. * used by @a x.
*/ */
map(const map& __x) map(const map& __x)
: _M_t(__x._M_t) { } : _M_t(__x._M_t) { }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/**
* @brief %Map move constructor.
* @param x A %map of identical element and allocator types.
*
* The newly-created %map contains the exact contents of @a x.
* The contents of @a x are a valid, but unspecified %map.
*/
map(map&& __x)
: _M_t(__x._M_t.key_comp(),
__x._M_t._M_get_Node_allocator())
{ this->swap(__x); }
#endif
/** /**
* @brief Builds a %map from a range. * @brief Builds a %map from a range.
* @param first An input iterator. * @param first An input iterator.
@ -184,9 +200,9 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* This is linear in N if the range is already sorted, and NlogN * This is linear in N if the range is already sorted, and NlogN
* otherwise (where N is distance(first,last)). * otherwise (where N is distance(first,last)).
*/ */
template <typename _InputIterator> template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last) map(_InputIterator __first, _InputIterator __last)
: _M_t(_Compare(), allocator_type()) : _M_t()
{ _M_t._M_insert_unique(__first, __last); } { _M_t._M_insert_unique(__first, __last); }
/** /**
@ -200,9 +216,10 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* This is linear in N if the range is already sorted, and NlogN * This is linear in N if the range is already sorted, and NlogN
* otherwise (where N is distance(first,last)). * otherwise (where N is distance(first,last)).
*/ */
template <typename _InputIterator> template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last, map(_InputIterator __first, _InputIterator __last,
const _Compare& __comp, const allocator_type& __a = allocator_type()) const _Compare& __comp,
const allocator_type& __a = allocator_type())
: _M_t(__comp, __a) : _M_t(__comp, __a)
{ _M_t._M_insert_unique(__first, __last); } { _M_t._M_insert_unique(__first, __last); }
@ -216,7 +233,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
*/ */
/** /**
* @brief Map assignment operator. * @brief %Map assignment operator.
* @param x A %map of identical element and allocator types. * @param x A %map of identical element and allocator types.
* *
* All the elements of @a x are copied, but unlike the copy constructor, * All the elements of @a x are copied, but unlike the copy constructor,
@ -229,6 +246,22 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
return *this; return *this;
} }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/**
* @brief %Map move assignment operator.
* @param x A %map of identical element and allocator types.
*
* The contents of @a x are moved into this map (without copying).
* @a x is a valid, but unspecified %map.
*/
map&
operator=(map&& __x)
{
this->swap(__x);
return *this;
}
#endif
/// Get a copy of the memory allocation object. /// Get a copy of the memory allocation object.
allocator_type allocator_type
get_allocator() const get_allocator() const
@ -434,7 +467,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* *
* Complexity similar to that of the range constructor. * Complexity similar to that of the range constructor.
*/ */
template <typename _InputIterator> template<typename _InputIterator>
void void
insert(_InputIterator __first, _InputIterator __last) insert(_InputIterator __first, _InputIterator __last)
{ _M_t._M_insert_unique(__first, __last); } { _M_t._M_insert_unique(__first, __last); }
@ -495,7 +528,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* that std::swap(m1,m2) will feed to this function. * that std::swap(m1,m2) will feed to this function.
*/ */
void void
#ifdef __GXX_EXPERIMENTAL_CXX0X__
swap(map&& __x)
#else
swap(map& __x) swap(map& __x)
#endif
{ _M_t.swap(__x._M_t); } { _M_t.swap(__x._M_t); }
/** /**
@ -656,15 +693,15 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
equal_range(const key_type& __x) const equal_range(const key_type& __x) const
{ return _M_t.equal_range(__x); } { return _M_t.equal_range(__x); }
template <typename _K1, typename _T1, typename _C1, typename _A1> template<typename _K1, typename _T1, typename _C1, typename _A1>
friend bool friend bool
operator== (const map<_K1, _T1, _C1, _A1>&, operator==(const map<_K1, _T1, _C1, _A1>&,
const map<_K1, _T1, _C1, _A1>&);
template <typename _K1, typename _T1, typename _C1, typename _A1>
friend bool
operator< (const map<_K1, _T1, _C1, _A1>&,
const map<_K1, _T1, _C1, _A1>&); const map<_K1, _T1, _C1, _A1>&);
template<typename _K1, typename _T1, typename _C1, typename _A1>
friend bool
operator<(const map<_K1, _T1, _C1, _A1>&,
const map<_K1, _T1, _C1, _A1>&);
}; };
/** /**
@ -677,7 +714,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* maps. Maps are considered equivalent if their sizes are equal, * maps. Maps are considered equivalent if their sizes are equal,
* and if corresponding elements compare equal. * and if corresponding elements compare equal.
*/ */
template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool inline bool
operator==(const map<_Key, _Tp, _Compare, _Alloc>& __x, operator==(const map<_Key, _Tp, _Compare, _Alloc>& __x,
const map<_Key, _Tp, _Compare, _Alloc>& __y) const map<_Key, _Tp, _Compare, _Alloc>& __y)
@ -694,47 +731,61 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* *
* See std::lexicographical_compare() for how the determination is made. * See std::lexicographical_compare() for how the determination is made.
*/ */
template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool inline bool
operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x, operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x,
const map<_Key, _Tp, _Compare, _Alloc>& __y) const map<_Key, _Tp, _Compare, _Alloc>& __y)
{ return __x._M_t < __y._M_t; } { return __x._M_t < __y._M_t; }
/// Based on operator== /// Based on operator==
template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool inline bool
operator!=(const map<_Key, _Tp, _Compare, _Alloc>& __x, operator!=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
const map<_Key, _Tp, _Compare, _Alloc>& __y) const map<_Key, _Tp, _Compare, _Alloc>& __y)
{ return !(__x == __y); } { return !(__x == __y); }
/// Based on operator< /// Based on operator<
template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool inline bool
operator>(const map<_Key, _Tp, _Compare, _Alloc>& __x, operator>(const map<_Key, _Tp, _Compare, _Alloc>& __x,
const map<_Key, _Tp, _Compare, _Alloc>& __y) const map<_Key, _Tp, _Compare, _Alloc>& __y)
{ return __y < __x; } { return __y < __x; }
/// Based on operator< /// Based on operator<
template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool inline bool
operator<=(const map<_Key, _Tp, _Compare, _Alloc>& __x, operator<=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
const map<_Key, _Tp, _Compare, _Alloc>& __y) const map<_Key, _Tp, _Compare, _Alloc>& __y)
{ return !(__y < __x); } { return !(__y < __x); }
/// Based on operator< /// Based on operator<
template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool inline bool
operator>=(const map<_Key, _Tp, _Compare, _Alloc>& __x, operator>=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
const map<_Key, _Tp, _Compare, _Alloc>& __y) const map<_Key, _Tp, _Compare, _Alloc>& __y)
{ return !(__x < __y); } { return !(__x < __y); }
/// See std::map::swap(). /// See std::map::swap().
template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline void inline void
swap(map<_Key, _Tp, _Compare, _Alloc>& __x, swap(map<_Key, _Tp, _Compare, _Alloc>& __x,
map<_Key, _Tp, _Compare, _Alloc>& __y) map<_Key, _Tp, _Compare, _Alloc>& __y)
{ __x.swap(__y); } { __x.swap(__y); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline void
swap(map<_Key, _Tp, _Compare, _Alloc>&& __x,
map<_Key, _Tp, _Compare, _Alloc>& __y)
{ __x.swap(__y); }
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline void
swap(map<_Key, _Tp, _Compare, _Alloc>& __x,
map<_Key, _Tp, _Compare, _Alloc>&& __y)
{ __x.swap(__y); }
#endif
_GLIBCXX_END_NESTED_NAMESPACE _GLIBCXX_END_NESTED_NAMESPACE
#endif /* _STL_MAP_H */ #endif /* _STL_MAP_H */

View File

@ -153,11 +153,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* @brief Default constructor creates no elements. * @brief Default constructor creates no elements.
*/ */
multimap() multimap()
: _M_t(_Compare(), allocator_type()) { } : _M_t() { }
// for some reason this was made a separate function
/** /**
* @brief Default constructor creates no elements. * @brief Creates a %multimap with no elements.
* @param comp A comparison object.
* @param a An allocator object.
*/ */
explicit explicit
multimap(const _Compare& __comp, multimap(const _Compare& __comp,
@ -168,12 +169,26 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* @brief %Multimap copy constructor. * @brief %Multimap copy constructor.
* @param x A %multimap of identical element and allocator types. * @param x A %multimap of identical element and allocator types.
* *
* The newly-created %multimap uses a copy of the allocation object used * The newly-created %multimap uses a copy of the allocation object
* by @a x. * used by @a x.
*/ */
multimap(const multimap& __x) multimap(const multimap& __x)
: _M_t(__x._M_t) { } : _M_t(__x._M_t) { }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/**
* @brief %Multimap move constructor.
* @param x A %multimap of identical element and allocator types.
*
* The newly-created %multimap contains the exact contents of @a x.
* The contents of @a x are a valid, but unspecified %multimap.
*/
multimap(multimap&& __x)
: _M_t(__x._M_t.key_comp(),
__x._M_t._M_get_Node_allocator())
{ this->swap(__x); }
#endif
/** /**
* @brief Builds a %multimap from a range. * @brief Builds a %multimap from a range.
* @param first An input iterator. * @param first An input iterator.
@ -183,10 +198,10 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* [first,last). This is linear in N if the range is already sorted, * [first,last). This is linear in N if the range is already sorted,
* and NlogN otherwise (where N is distance(first,last)). * and NlogN otherwise (where N is distance(first,last)).
*/ */
template <typename _InputIterator> template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last) multimap(_InputIterator __first, _InputIterator __last)
: _M_t(_Compare(), allocator_type()) : _M_t()
{ _M_t._M_insert_equal(__first, __last); } { _M_t._M_insert_unique(__first, __last); }
/** /**
* @brief Builds a %multimap from a range. * @brief Builds a %multimap from a range.
@ -199,7 +214,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* [first,last). This is linear in N if the range is already sorted, * [first,last). This is linear in N if the range is already sorted,
* and NlogN otherwise (where N is distance(first,last)). * and NlogN otherwise (where N is distance(first,last)).
*/ */
template <typename _InputIterator> template<typename _InputIterator>
multimap(_InputIterator __first, _InputIterator __last, multimap(_InputIterator __first, _InputIterator __last,
const _Compare& __comp, const _Compare& __comp,
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
@ -229,6 +244,22 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
return *this; return *this;
} }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/**
* @brief %Multimap move assignment operator.
* @param x A %multimap of identical element and allocator types.
*
* The contents of @a x are moved into this multimap (without copying).
* @a x is a valid, but unspecified multimap.
*/
multimap&
operator=(multimap&& __x)
{
this->swap(__x);
return *this;
}
#endif
/// Get a copy of the memory allocation object. /// Get a copy of the memory allocation object.
allocator_type allocator_type
get_allocator() const get_allocator() const
@ -372,7 +403,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* *
* Complexity similar to that of the range constructor. * Complexity similar to that of the range constructor.
*/ */
template <typename _InputIterator> template<typename _InputIterator>
void void
insert(_InputIterator __first, _InputIterator __last) insert(_InputIterator __first, _InputIterator __last)
{ _M_t._M_insert_equal(__first, __last); } { _M_t._M_insert_equal(__first, __last); }
@ -433,7 +464,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* std::swap(m1,m2) will feed to this function. * std::swap(m1,m2) will feed to this function.
*/ */
void void
#ifdef __GXX_EXPERIMENTAL_CXX0X__
swap(multimap&& __x)
#else
swap(multimap& __x) swap(multimap& __x)
#endif
{ _M_t.swap(__x._M_t); } { _M_t.swap(__x._M_t); }
/** /**
@ -587,15 +622,15 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
equal_range(const key_type& __x) const equal_range(const key_type& __x) const
{ return _M_t.equal_range(__x); } { return _M_t.equal_range(__x); }
template <typename _K1, typename _T1, typename _C1, typename _A1> template<typename _K1, typename _T1, typename _C1, typename _A1>
friend bool friend bool
operator== (const multimap<_K1, _T1, _C1, _A1>&, operator==(const multimap<_K1, _T1, _C1, _A1>&,
const multimap<_K1, _T1, _C1, _A1>&);
template <typename _K1, typename _T1, typename _C1, typename _A1>
friend bool
operator< (const multimap<_K1, _T1, _C1, _A1>&,
const multimap<_K1, _T1, _C1, _A1>&); const multimap<_K1, _T1, _C1, _A1>&);
template<typename _K1, typename _T1, typename _C1, typename _A1>
friend bool
operator<(const multimap<_K1, _T1, _C1, _A1>&,
const multimap<_K1, _T1, _C1, _A1>&);
}; };
/** /**
@ -608,7 +643,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* multimaps. Multimaps are considered equivalent if their sizes are equal, * multimaps. Multimaps are considered equivalent if their sizes are equal,
* and if corresponding elements compare equal. * and if corresponding elements compare equal.
*/ */
template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool inline bool
operator==(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, operator==(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
const multimap<_Key, _Tp, _Compare, _Alloc>& __y) const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
@ -625,47 +660,61 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* *
* See std::lexicographical_compare() for how the determination is made. * See std::lexicographical_compare() for how the determination is made.
*/ */
template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool inline bool
operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
const multimap<_Key, _Tp, _Compare, _Alloc>& __y) const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
{ return __x._M_t < __y._M_t; } { return __x._M_t < __y._M_t; }
/// Based on operator== /// Based on operator==
template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool inline bool
operator!=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, operator!=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
const multimap<_Key, _Tp, _Compare, _Alloc>& __y) const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
{ return !(__x == __y); } { return !(__x == __y); }
/// Based on operator< /// Based on operator<
template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool inline bool
operator>(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, operator>(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
const multimap<_Key, _Tp, _Compare, _Alloc>& __y) const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
{ return __y < __x; } { return __y < __x; }
/// Based on operator< /// Based on operator<
template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool inline bool
operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
const multimap<_Key, _Tp, _Compare, _Alloc>& __y) const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
{ return !(__y < __x); } { return !(__y < __x); }
/// Based on operator< /// Based on operator<
template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline bool inline bool
operator>=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, operator>=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
const multimap<_Key, _Tp, _Compare, _Alloc>& __y) const multimap<_Key, _Tp, _Compare, _Alloc>& __y)
{ return !(__x < __y); } { return !(__x < __y); }
/// See std::multimap::swap(). /// See std::multimap::swap().
template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline void inline void
swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x, swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x,
multimap<_Key, _Tp, _Compare, _Alloc>& __y) multimap<_Key, _Tp, _Compare, _Alloc>& __y)
{ __x.swap(__y); } { __x.swap(__y); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline void
swap(multimap<_Key, _Tp, _Compare, _Alloc>&& __x,
multimap<_Key, _Tp, _Compare, _Alloc>& __y)
{ __x.swap(__y); }
template<typename _Key, typename _Tp, typename _Compare, typename _Alloc>
inline void
swap(multimap<_Key, _Tp, _Compare, _Alloc>& __x,
multimap<_Key, _Tp, _Compare, _Alloc>&& __y)
{ __x.swap(__y); }
#endif
_GLIBCXX_END_NESTED_NAMESPACE _GLIBCXX_END_NESTED_NAMESPACE
#endif /* _STL_MULTIMAP_H */ #endif /* _STL_MULTIMAP_H */

View File

@ -86,8 +86,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* called (*_unique versus *_equal, same as the standard). * called (*_unique versus *_equal, same as the standard).
* @endif * @endif
*/ */
template <class _Key, class _Compare = std::less<_Key>, template <typename _Key, typename _Compare = std::less<_Key>,
class _Alloc = std::allocator<_Key> > typename _Alloc = std::allocator<_Key> >
class multiset class multiset
{ {
// concept requirements // concept requirements
@ -130,13 +130,17 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
typedef typename _Rep_type::difference_type difference_type; typedef typename _Rep_type::difference_type difference_type;
// allocation/deallocation // allocation/deallocation
/** /**
* @brief Default constructor creates no elements. * @brief Default constructor creates no elements.
*/ */
multiset() multiset()
: _M_t(_Compare(), allocator_type()) { } : _M_t() { }
/**
* @brief Creates a %multiset with no elements.
* @param comp Comparator to use.
* @param a An allocator object.
*/
explicit explicit
multiset(const _Compare& __comp, multiset(const _Compare& __comp,
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
@ -151,9 +155,9 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* [first,last). This is linear in N if the range is already sorted, * [first,last). This is linear in N if the range is already sorted,
* and NlogN otherwise (where N is distance(first,last)). * and NlogN otherwise (where N is distance(first,last)).
*/ */
template <class _InputIterator> template<typename _InputIterator>
multiset(_InputIterator __first, _InputIterator __last) multiset(_InputIterator __first, _InputIterator __last)
: _M_t(_Compare(), allocator_type()) : _M_t()
{ _M_t._M_insert_equal(__first, __last); } { _M_t._M_insert_equal(__first, __last); }
/** /**
@ -167,7 +171,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* [first,last). This is linear in N if the range is already sorted, * [first,last). This is linear in N if the range is already sorted,
* and NlogN otherwise (where N is distance(first,last)). * and NlogN otherwise (where N is distance(first,last)).
*/ */
template <class _InputIterator> template<typename _InputIterator>
multiset(_InputIterator __first, _InputIterator __last, multiset(_InputIterator __first, _InputIterator __last,
const _Compare& __comp, const _Compare& __comp,
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
@ -181,9 +185,23 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* The newly-created %multiset uses a copy of the allocation object used * The newly-created %multiset uses a copy of the allocation object used
* by @a x. * by @a x.
*/ */
multiset(const multiset<_Key,_Compare,_Alloc>& __x) multiset(const multiset& __x)
: _M_t(__x._M_t) { } : _M_t(__x._M_t) { }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/**
* @brief %Multiset move constructor.
* @param x A %multiset of identical element and allocator types.
*
* The newly-created %multiset contains the exact contents of @a x.
* The contents of @a x are a valid, but unspecified %multiset.
*/
multiset(multiset&& __x)
: _M_t(__x._M_t.key_comp(),
__x._M_t._M_get_Node_allocator())
{ this->swap(__x); }
#endif
/** /**
* @brief %Multiset assignment operator. * @brief %Multiset assignment operator.
* @param x A %multiset of identical element and allocator types. * @param x A %multiset of identical element and allocator types.
@ -191,13 +209,29 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* All the elements of @a x are copied, but unlike the copy constructor, * All the elements of @a x are copied, but unlike the copy constructor,
* the allocator object is not copied. * the allocator object is not copied.
*/ */
multiset<_Key,_Compare,_Alloc>& multiset&
operator=(const multiset<_Key,_Compare,_Alloc>& __x) operator=(const multiset& __x)
{ {
_M_t = __x._M_t; _M_t = __x._M_t;
return *this; return *this;
} }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/**
* @brief %Multiset move assignment operator.
* @param x A %multiset of identical element and allocator types.
*
* The contents of @a x are moved into this %multiset (without copying).
* @a x is a valid, but unspecified %multiset.
*/
multiset&
operator=(multiset&& __x)
{
this->swap(__x);
return *this;
}
#endif
// accessors: // accessors:
/// Returns the comparison object. /// Returns the comparison object.
@ -276,7 +310,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* std::swap(s1,s2) will feed to this function. * std::swap(s1,s2) will feed to this function.
*/ */
void void
swap(multiset<_Key, _Compare, _Alloc>& __x) #ifdef __GXX_EXPERIMENTAL_CXX0X__
swap(multiset&& __x)
#else
swap(multiset& __x)
#endif
{ _M_t.swap(__x._M_t); } { _M_t.swap(__x._M_t); }
// insert/erase // insert/erase
@ -327,7 +365,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* *
* Complexity similar to that of the range constructor. * Complexity similar to that of the range constructor.
*/ */
template <class _InputIterator> template<typename _InputIterator>
void void
insert(_InputIterator __first, _InputIterator __last) insert(_InputIterator __first, _InputIterator __last)
{ _M_t._M_insert_equal(__first, __last); } { _M_t._M_insert_equal(__first, __last); }
@ -481,12 +519,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
equal_range(const key_type& __x) const equal_range(const key_type& __x) const
{ return _M_t.equal_range(__x); } { return _M_t.equal_range(__x); }
template <class _K1, class _C1, class _A1> template<typename _K1, typename _C1, typename _A1>
friend bool friend bool
operator== (const multiset<_K1, _C1, _A1>&, operator==(const multiset<_K1, _C1, _A1>&,
const multiset<_K1, _C1, _A1>&); const multiset<_K1, _C1, _A1>&);
template <class _K1, class _C1, class _A1> template<typename _K1, typename _C1, typename _A1>
friend bool friend bool
operator< (const multiset<_K1, _C1, _A1>&, operator< (const multiset<_K1, _C1, _A1>&,
const multiset<_K1, _C1, _A1>&); const multiset<_K1, _C1, _A1>&);
@ -503,7 +541,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* Multisets are considered equivalent if their sizes are equal, and if * Multisets are considered equivalent if their sizes are equal, and if
* corresponding elements compare equal. * corresponding elements compare equal.
*/ */
template <class _Key, class _Compare, class _Alloc> template<typename _Key, typename _Compare, typename _Alloc>
inline bool inline bool
operator==(const multiset<_Key, _Compare, _Alloc>& __x, operator==(const multiset<_Key, _Compare, _Alloc>& __x,
const multiset<_Key, _Compare, _Alloc>& __y) const multiset<_Key, _Compare, _Alloc>& __y)
@ -520,47 +558,61 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* *
* See std::lexicographical_compare() for how the determination is made. * See std::lexicographical_compare() for how the determination is made.
*/ */
template <class _Key, class _Compare, class _Alloc> template<typename _Key, typename _Compare, typename _Alloc>
inline bool inline bool
operator<(const multiset<_Key, _Compare, _Alloc>& __x, operator<(const multiset<_Key, _Compare, _Alloc>& __x,
const multiset<_Key, _Compare, _Alloc>& __y) const multiset<_Key, _Compare, _Alloc>& __y)
{ return __x._M_t < __y._M_t; } { return __x._M_t < __y._M_t; }
/// Returns !(x == y). /// Returns !(x == y).
template <class _Key, class _Compare, class _Alloc> template<typename _Key, typename _Compare, typename _Alloc>
inline bool inline bool
operator!=(const multiset<_Key, _Compare, _Alloc>& __x, operator!=(const multiset<_Key, _Compare, _Alloc>& __x,
const multiset<_Key, _Compare, _Alloc>& __y) const multiset<_Key, _Compare, _Alloc>& __y)
{ return !(__x == __y); } { return !(__x == __y); }
/// Returns y < x. /// Returns y < x.
template <class _Key, class _Compare, class _Alloc> template<typename _Key, typename _Compare, typename _Alloc>
inline bool inline bool
operator>(const multiset<_Key,_Compare,_Alloc>& __x, operator>(const multiset<_Key,_Compare,_Alloc>& __x,
const multiset<_Key,_Compare,_Alloc>& __y) const multiset<_Key,_Compare,_Alloc>& __y)
{ return __y < __x; } { return __y < __x; }
/// Returns !(y < x) /// Returns !(y < x)
template <class _Key, class _Compare, class _Alloc> template<typename _Key, typename _Compare, typename _Alloc>
inline bool inline bool
operator<=(const multiset<_Key, _Compare, _Alloc>& __x, operator<=(const multiset<_Key, _Compare, _Alloc>& __x,
const multiset<_Key, _Compare, _Alloc>& __y) const multiset<_Key, _Compare, _Alloc>& __y)
{ return !(__y < __x); } { return !(__y < __x); }
/// Returns !(x < y) /// Returns !(x < y)
template <class _Key, class _Compare, class _Alloc> template<typename _Key, typename _Compare, typename _Alloc>
inline bool inline bool
operator>=(const multiset<_Key, _Compare, _Alloc>& __x, operator>=(const multiset<_Key, _Compare, _Alloc>& __x,
const multiset<_Key, _Compare, _Alloc>& __y) const multiset<_Key, _Compare, _Alloc>& __y)
{ return !(__x < __y); } { return !(__x < __y); }
/// See std::multiset::swap(). /// See std::multiset::swap().
template <class _Key, class _Compare, class _Alloc> template<typename _Key, typename _Compare, typename _Alloc>
inline void inline void
swap(multiset<_Key, _Compare, _Alloc>& __x, swap(multiset<_Key, _Compare, _Alloc>& __x,
multiset<_Key, _Compare, _Alloc>& __y) multiset<_Key, _Compare, _Alloc>& __y)
{ __x.swap(__y); } { __x.swap(__y); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Key, typename _Compare, typename _Alloc>
inline void
swap(multiset<_Key, _Compare, _Alloc>&& __x,
multiset<_Key, _Compare, _Alloc>& __y)
{ __x.swap(__y); }
template<typename _Key, typename _Compare, typename _Alloc>
inline void
swap(multiset<_Key, _Compare, _Alloc>& __x,
multiset<_Key, _Compare, _Alloc>&& __y)
{ __x.swap(__y); }
#endif
_GLIBCXX_END_NESTED_NAMESPACE _GLIBCXX_END_NESTED_NAMESPACE
#endif /* _STL_MULTISET_H */ #endif /* _STL_MULTISET_H */

View File

@ -89,8 +89,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* called (*_unique versus *_equal, same as the standard). * called (*_unique versus *_equal, same as the standard).
* @endif * @endif
*/ */
template<class _Key, class _Compare = std::less<_Key>, template<typename _Key, typename _Compare = std::less<_Key>,
class _Alloc = std::allocator<_Key> > typename _Alloc = std::allocator<_Key> >
class set class set
{ {
// concept requirements // concept requirements
@ -137,20 +137,21 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
//@} //@}
// allocation/deallocation // allocation/deallocation
/// Default constructor creates no elements.
set()
: _M_t(_Compare(), allocator_type()) {}
/** /**
* @brief Default constructor creates no elements. * @brief Default constructor creates no elements.
* */
set()
: _M_t() { }
/**
* @brief Creates a %set with no elements.
* @param comp Comparator to use. * @param comp Comparator to use.
* @param a Allocator to use. * @param a An allocator object.
*/ */
explicit explicit
set(const _Compare& __comp, set(const _Compare& __comp,
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
: _M_t(__comp, __a) {} : _M_t(__comp, __a) { }
/** /**
* @brief Builds a %set from a range. * @brief Builds a %set from a range.
@ -161,9 +162,9 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* This is linear in N if the range is already sorted, and NlogN * This is linear in N if the range is already sorted, and NlogN
* otherwise (where N is distance(first,last)). * otherwise (where N is distance(first,last)).
*/ */
template<class _InputIterator> template<typename _InputIterator>
set(_InputIterator __first, _InputIterator __last) set(_InputIterator __first, _InputIterator __last)
: _M_t(_Compare(), allocator_type()) : _M_t()
{ _M_t._M_insert_unique(__first, __last); } { _M_t._M_insert_unique(__first, __last); }
/** /**
@ -177,7 +178,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* This is linear in N if the range is already sorted, and NlogN * This is linear in N if the range is already sorted, and NlogN
* otherwise (where N is distance(first,last)). * otherwise (where N is distance(first,last)).
*/ */
template<class _InputIterator> template<typename _InputIterator>
set(_InputIterator __first, _InputIterator __last, set(_InputIterator __first, _InputIterator __last,
const _Compare& __comp, const _Compare& __comp,
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
@ -185,29 +186,59 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
{ _M_t._M_insert_unique(__first, __last); } { _M_t._M_insert_unique(__first, __last); }
/** /**
* @brief Set copy constructor. * @brief %Set copy constructor.
* @param x A %set of identical element and allocator types. * @param x A %set of identical element and allocator types.
* *
* The newly-created %set uses a copy of the allocation object used * The newly-created %set uses a copy of the allocation object used
* by @a x. * by @a x.
*/ */
set(const set<_Key,_Compare,_Alloc>& __x) set(const set& __x)
: _M_t(__x._M_t) { } : _M_t(__x._M_t) { }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/**
* @brief %Set move constructor
* @param x A %set of identical element and allocator types.
*
* The newly-created %set contains the exact contents of @a x.
* The contents of @a x are a valid, but unspecified %set.
*/
set(set&& __x)
: _M_t(__x._M_t.key_comp(),
__x._M_t._M_get_Node_allocator())
{ this->swap(__x); }
#endif
/** /**
* @brief Set assignment operator. * @brief %Set assignment operator.
* @param x A %set of identical element and allocator types. * @param x A %set of identical element and allocator types.
* *
* All the elements of @a x are copied, but unlike the copy constructor, * All the elements of @a x are copied, but unlike the copy constructor,
* the allocator object is not copied. * the allocator object is not copied.
*/ */
set<_Key,_Compare,_Alloc>& set&
operator=(const set<_Key, _Compare, _Alloc>& __x) operator=(const set& __x)
{ {
_M_t = __x._M_t; _M_t = __x._M_t;
return *this; return *this;
} }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/**
* @brief %Set move assignment operator.
* @param x A %set of identical element and allocator types.
*
* The contents of @a x are moved into this %set (without copying).
* @a x is a valid, but unspecified %set.
*/
set&
operator=(set&& __x)
{
this->swap(__x);
return *this;
}
#endif
// accessors: // accessors:
/// Returns the comparison object with which the %set was constructed. /// Returns the comparison object with which the %set was constructed.
@ -284,7 +315,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* std::swap(s1,s2) will feed to this function. * std::swap(s1,s2) will feed to this function.
*/ */
void void
swap(set<_Key,_Compare,_Alloc>& __x) #ifdef __GXX_EXPERIMENTAL_CXX0X__
swap(set&& __x)
#else
swap(set& __x)
#endif
{ _M_t.swap(__x._M_t); } { _M_t.swap(__x._M_t); }
// insert/erase // insert/erase
@ -301,7 +336,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* *
* Insertion requires logarithmic time. * Insertion requires logarithmic time.
*/ */
std::pair<iterator,bool> std::pair<iterator, bool>
insert(const value_type& __x) insert(const value_type& __x)
{ {
std::pair<typename _Rep_type::iterator, bool> __p = std::pair<typename _Rep_type::iterator, bool> __p =
@ -340,7 +375,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* *
* Complexity similar to that of the range constructor. * Complexity similar to that of the range constructor.
*/ */
template<class _InputIterator> template<typename _InputIterator>
void void
insert(_InputIterator __first, _InputIterator __last) insert(_InputIterator __first, _InputIterator __last)
{ _M_t._M_insert_unique(__first, __last); } { _M_t._M_insert_unique(__first, __last); }
@ -497,13 +532,13 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
{ return _M_t.equal_range(__x); } { return _M_t.equal_range(__x); }
//@} //@}
template<class _K1, class _C1, class _A1> template<typename _K1, typename _C1, typename _A1>
friend bool friend bool
operator== (const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&); operator==(const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&);
template<class _K1, class _C1, class _A1> template<typename _K1, typename _C1, typename _A1>
friend bool friend bool
operator< (const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&); operator<(const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&);
}; };
@ -517,7 +552,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* Sets are considered equivalent if their sizes are equal, and if * Sets are considered equivalent if their sizes are equal, and if
* corresponding elements compare equal. * corresponding elements compare equal.
*/ */
template<class _Key, class _Compare, class _Alloc> template<typename _Key, typename _Compare, typename _Alloc>
inline bool inline bool
operator==(const set<_Key, _Compare, _Alloc>& __x, operator==(const set<_Key, _Compare, _Alloc>& __x,
const set<_Key, _Compare, _Alloc>& __y) const set<_Key, _Compare, _Alloc>& __y)
@ -534,46 +569,58 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* *
* See std::lexicographical_compare() for how the determination is made. * See std::lexicographical_compare() for how the determination is made.
*/ */
template<class _Key, class _Compare, class _Alloc> template<typename _Key, typename _Compare, typename _Alloc>
inline bool inline bool
operator<(const set<_Key, _Compare, _Alloc>& __x, operator<(const set<_Key, _Compare, _Alloc>& __x,
const set<_Key, _Compare, _Alloc>& __y) const set<_Key, _Compare, _Alloc>& __y)
{ return __x._M_t < __y._M_t; } { return __x._M_t < __y._M_t; }
/// Returns !(x == y). /// Returns !(x == y).
template<class _Key, class _Compare, class _Alloc> template<typename _Key, typename _Compare, typename _Alloc>
inline bool inline bool
operator!=(const set<_Key, _Compare, _Alloc>& __x, operator!=(const set<_Key, _Compare, _Alloc>& __x,
const set<_Key, _Compare, _Alloc>& __y) const set<_Key, _Compare, _Alloc>& __y)
{ return !(__x == __y); } { return !(__x == __y); }
/// Returns y < x. /// Returns y < x.
template<class _Key, class _Compare, class _Alloc> template<typename _Key, typename _Compare, typename _Alloc>
inline bool inline bool
operator>(const set<_Key, _Compare, _Alloc>& __x, operator>(const set<_Key, _Compare, _Alloc>& __x,
const set<_Key, _Compare, _Alloc>& __y) const set<_Key, _Compare, _Alloc>& __y)
{ return __y < __x; } { return __y < __x; }
/// Returns !(y < x) /// Returns !(y < x)
template<class _Key, class _Compare, class _Alloc> template<typename _Key, typename _Compare, typename _Alloc>
inline bool inline bool
operator<=(const set<_Key, _Compare, _Alloc>& __x, operator<=(const set<_Key, _Compare, _Alloc>& __x,
const set<_Key, _Compare, _Alloc>& __y) const set<_Key, _Compare, _Alloc>& __y)
{ return !(__y < __x); } { return !(__y < __x); }
/// Returns !(x < y) /// Returns !(x < y)
template<class _Key, class _Compare, class _Alloc> template<typename _Key, typename _Compare, typename _Alloc>
inline bool inline bool
operator>=(const set<_Key, _Compare, _Alloc>& __x, operator>=(const set<_Key, _Compare, _Alloc>& __x,
const set<_Key, _Compare, _Alloc>& __y) const set<_Key, _Compare, _Alloc>& __y)
{ return !(__x < __y); } { return !(__x < __y); }
/// See std::set::swap(). /// See std::set::swap().
template<class _Key, class _Compare, class _Alloc> template<typename _Key, typename _Compare, typename _Alloc>
inline void inline void
swap(set<_Key, _Compare, _Alloc>& __x, set<_Key, _Compare, _Alloc>& __y) swap(set<_Key, _Compare, _Alloc>& __x, set<_Key, _Compare, _Alloc>& __y)
{ __x.swap(__y); } { __x.swap(__y); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Key, typename _Compare, typename _Alloc>
inline void
swap(set<_Key, _Compare, _Alloc>&& __x, set<_Key, _Compare, _Alloc>& __y)
{ __x.swap(__y); }
template<typename _Key, typename _Compare, typename _Alloc>
inline void
swap(set<_Key, _Compare, _Alloc>& __x, set<_Key, _Compare, _Alloc>&& __y)
{ __x.swap(__y); }
#endif
_GLIBCXX_END_NESTED_NAMESPACE _GLIBCXX_END_NESTED_NAMESPACE
#endif /* _STL_SET_H */ #endif /* _STL_SET_H */

View File

@ -400,16 +400,25 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_Rb_tree_node_base _M_header; _Rb_tree_node_base _M_header;
size_type _M_node_count; // Keeps track of size of tree. size_type _M_node_count; // Keeps track of size of tree.
_Rb_tree_impl(const _Node_allocator& __a = _Node_allocator(), _Rb_tree_impl()
const _Key_compare& __comp = _Key_compare()) : _Node_allocator(), _M_key_compare(), _M_header(),
: _Node_allocator(__a), _M_key_compare(__comp), _M_header(),
_M_node_count(0) _M_node_count(0)
{ _M_initialize(); }
_Rb_tree_impl(const _Key_compare& __comp, const _Node_allocator& __a)
: _Node_allocator(__a), _M_key_compare(__comp), _M_header(),
_M_node_count(0)
{ _M_initialize(); }
private:
void
_M_initialize()
{ {
this->_M_header._M_color = _S_red; this->_M_header._M_color = _S_red;
this->_M_header._M_parent = 0; this->_M_header._M_parent = 0;
this->_M_header._M_left = &this->_M_header; this->_M_header._M_left = &this->_M_header;
this->_M_header._M_right = &this->_M_header; this->_M_header._M_right = &this->_M_header;
} }
}; };
// Specialization for _Comparison types that are not capable of // Specialization for _Comparison types that are not capable of
@ -421,16 +430,25 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_Rb_tree_node_base _M_header; _Rb_tree_node_base _M_header;
size_type _M_node_count; // Keeps track of size of tree. size_type _M_node_count; // Keeps track of size of tree.
_Rb_tree_impl(const _Node_allocator& __a = _Node_allocator(), _Rb_tree_impl()
const _Key_compare& __comp = _Key_compare()) : _Node_allocator(), _M_key_compare(), _M_header(),
_M_node_count(0)
{ _M_initialize(); }
_Rb_tree_impl(const _Key_compare& __comp, const _Node_allocator& __a)
: _Node_allocator(__a), _M_key_compare(__comp), _M_header(), : _Node_allocator(__a), _M_key_compare(__comp), _M_header(),
_M_node_count(0) _M_node_count(0)
{ { _M_initialize(); }
private:
void
_M_initialize()
{
this->_M_header._M_color = _S_red; this->_M_header._M_color = _S_red;
this->_M_header._M_parent = 0; this->_M_header._M_parent = 0;
this->_M_header._M_left = &this->_M_header; this->_M_header._M_left = &this->_M_header;
this->_M_header._M_right = &this->_M_header; this->_M_header._M_right = &this->_M_header;
} }
}; };
_Rb_tree_impl<_Compare> _M_impl; _Rb_tree_impl<_Compare> _M_impl;
@ -571,19 +589,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
public: public:
// allocation/deallocation // allocation/deallocation
_Rb_tree() _Rb_tree() { }
{ }
_Rb_tree(const _Compare& __comp) _Rb_tree(const _Compare& __comp,
: _M_impl(allocator_type(), __comp) const allocator_type& __a = allocator_type())
{ } : _M_impl(__comp, __a) { }
_Rb_tree(const _Compare& __comp, const allocator_type& __a) _Rb_tree(const _Rb_tree& __x)
: _M_impl(__a, __comp) : _M_impl(__x._M_impl._M_key_compare, __x._M_get_Node_allocator())
{ }
_Rb_tree(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x)
: _M_impl(__x._M_get_Node_allocator(), __x._M_impl._M_key_compare)
{ {
if (__x._M_root() != 0) if (__x._M_root() != 0)
{ {
@ -597,8 +610,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
~_Rb_tree() ~_Rb_tree()
{ _M_erase(_M_begin()); } { _M_erase(_M_begin()); }
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& _Rb_tree&
operator=(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x); operator=(const _Rb_tree& __x);
// Accessors. // Accessors.
_Compare _Compare
@ -659,7 +672,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ return get_allocator().max_size(); } { return get_allocator().max_size(); }
void void
swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __t); #ifdef __GXX_EXPERIMENTAL_CXX0X__
swap(_Rb_tree&& __t);
#else
swap(_Rb_tree& __t);
#endif
// Insert/erase. // Insert/erase.
pair<iterator, bool> pair<iterator, bool>
@ -1060,7 +1077,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
typename _Compare, typename _Alloc> typename _Compare, typename _Alloc>
void void
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
#ifdef __GXX_EXPERIMENTAL_CXX0X__
swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&& __t)
#else
swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __t) swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __t)
#endif
{ {
if (_M_root() == 0) if (_M_root() == 0)
{ {

View File

@ -84,6 +84,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
_Tp* _M_start; _Tp* _M_start;
_Tp* _M_finish; _Tp* _M_finish;
_Tp* _M_end_of_storage; _Tp* _M_end_of_storage;
_Vector_impl()
: _Tp_alloc_type(), _M_start(0), _M_finish(0), _M_end_of_storage(0)
{ }
_Vector_impl(_Tp_alloc_type const& __a) _Vector_impl(_Tp_alloc_type const& __a)
: _Tp_alloc_type(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0) : _Tp_alloc_type(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0)
{ } { }
@ -104,9 +109,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
get_allocator() const get_allocator() const
{ return allocator_type(_M_get_Tp_allocator()); } { return allocator_type(_M_get_Tp_allocator()); }
_Vector_base()
: _M_impl() { }
_Vector_base(const allocator_type& __a) _Vector_base(const allocator_type& __a)
: _M_impl(__a) : _M_impl(__a) { }
{ }
_Vector_base(size_t __n, const allocator_type& __a) _Vector_base(size_t __n, const allocator_type& __a)
: _M_impl(__a) : _M_impl(__a)
@ -194,15 +201,22 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
/** /**
* @brief Default constructor creates no elements. * @brief Default constructor creates no elements.
*/ */
explicit vector()
vector(const allocator_type& __a = allocator_type()) : _Base() { }
: _Base(__a)
{ }
/** /**
* @brief Create a %vector with copies of an exemplar element. * @brief Creates a %vector with no elements.
* @param a An allocator object.
*/
explicit
vector(const allocator_type& __a)
: _Base(__a) { }
/**
* @brief Creates a %vector with copies of an exemplar element.
* @param n The number of elements to initially create. * @param n The number of elements to initially create.
* @param value An element to copy. * @param value An element to copy.
* @param a An allocator.
* *
* This constructor fills the %vector with @a n copies of @a value. * This constructor fills the %vector with @a n copies of @a value.
*/ */
@ -229,10 +243,24 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
_M_get_Tp_allocator()); _M_get_Tp_allocator());
} }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/**
* @brief %Vector move constructor.
* @param x A %vector of identical element and allocator types.
*
* The newly-created %vector contains the exact contents of @a x.
* The contents of @a x are a valid, but unspecified %vector.
*/
vector(vector&& __x)
: _Base(__x._M_get_Tp_allocator())
{ this->swap(__x); }
#endif
/** /**
* @brief Builds a %vector from a range. * @brief Builds a %vector from a range.
* @param first An input iterator. * @param first An input iterator.
* @param last An input iterator. * @param last An input iterator.
* @param a An allocator.
* *
* Create a %vector consisting of copies of the elements from * Create a %vector consisting of copies of the elements from
* [first,last). * [first,last).
@ -275,6 +303,22 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
vector& vector&
operator=(const vector& __x); operator=(const vector& __x);
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/**
* @brief %Vector move assignment operator.
* @param x A %vector of identical element and allocator types.
*
* The contents of @a x are moved into this %vector (without copying).
* @a x is a valid, but unspecified %vector.
*/
vector&
operator=(vector&& __x)
{
this->swap(__x);
return *this;
}
#endif
/** /**
* @brief Assigns a given value to a %vector. * @brief Assigns a given value to a %vector.
* @param n Number of elements to be assigned. * @param n Number of elements to be assigned.
@ -721,7 +765,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
* std::swap(v1,v2) will feed to this function. * std::swap(v1,v2) will feed to this function.
*/ */
void void
#ifdef __GXX_EXPERIMENTAL_CXX0X__
swap(vector&& __x)
#else
swap(vector& __x) swap(vector& __x)
#endif
{ {
std::swap(this->_M_impl._M_start, __x._M_impl._M_start); std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish); std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);
@ -1006,6 +1054,18 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y) swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y)
{ __x.swap(__y); } { __x.swap(__y); }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Tp, typename _Alloc>
inline void
swap(vector<_Tp, _Alloc>&& __x, vector<_Tp, _Alloc>& __y)
{ __x.swap(__y); }
template<typename _Tp, typename _Alloc>
inline void
swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>&& __y)
{ __x.swap(__y); }
#endif
_GLIBCXX_END_NESTED_NAMESPACE _GLIBCXX_END_NESTED_NAMESPACE
#endif /* _STL_VECTOR_H */ #endif /* _STL_VECTOR_H */

View File

@ -19,7 +19,7 @@
// USA. // USA.
// { dg-do compile } // { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 1297 } // { dg-error "no matching" "" { target *-*-* } 1349 }
// { dg-excess-errors "" } // { dg-excess-errors "" }
#include <deque> #include <deque>

View File

@ -19,7 +19,7 @@
// USA. // USA.
// { dg-do compile } // { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 1232 } // { dg-error "no matching" "" { target *-*-* } 1284 }
// { dg-excess-errors "" } // { dg-excess-errors "" }
#include <deque> #include <deque>

View File

@ -19,7 +19,7 @@
// USA. // USA.
// { dg-do compile } // { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 1232 } // { dg-error "no matching" "" { target *-*-* } 1284 }
// { dg-excess-errors "" } // { dg-excess-errors "" }
#include <deque> #include <deque>

View File

@ -19,7 +19,7 @@
// USA. // USA.
// { dg-do compile } // { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 1377 } // { dg-error "no matching" "" { target *-*-* } 1429 }
// { dg-excess-errors "" } // { dg-excess-errors "" }
#include <deque> #include <deque>

View File

@ -19,7 +19,7 @@
// USA. // USA.
// { dg-do compile } // { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 1138 } // { dg-error "no matching" "" { target *-*-* } 1188 }
// { dg-excess-errors "" } // { dg-excess-errors "" }
#include <list> #include <list>

View File

@ -19,7 +19,7 @@
// USA. // USA.
// { dg-do compile } // { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 1107 } // { dg-error "no matching" "" { target *-*-* } 1157 }
// { dg-excess-errors "" } // { dg-excess-errors "" }
#include <list> #include <list>

View File

@ -19,7 +19,7 @@
// USA. // USA.
// { dg-do compile } // { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 1107 } // { dg-error "no matching" "" { target *-*-* } 1157 }
// { dg-excess-errors "" } // { dg-excess-errors "" }
#include <list> #include <list>

View File

@ -19,7 +19,7 @@
// USA. // USA.
// { dg-do compile } // { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 1107 } // { dg-error "no matching" "" { target *-*-* } 1157 }
// { dg-excess-errors "" } // { dg-excess-errors "" }
#include <list> #include <list>

View File

@ -19,7 +19,7 @@
// USA. // USA.
// { dg-do compile } // { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 847 } // { dg-error "no matching" "" { target *-*-* } 895 }
// { dg-excess-errors "" } // { dg-excess-errors "" }
#include <vector> #include <vector>

View File

@ -19,7 +19,7 @@
// USA. // USA.
// { dg-do compile } // { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 787 } // { dg-error "no matching" "" { target *-*-* } 835 }
// { dg-excess-errors "" } // { dg-excess-errors "" }
#include <vector> #include <vector>

View File

@ -19,7 +19,7 @@
// USA. // USA.
// { dg-do compile } // { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 787 } // { dg-error "no matching" "" { target *-*-* } 835 }
// { dg-excess-errors "" } // { dg-excess-errors "" }
#include <vector> #include <vector>

View File

@ -19,7 +19,7 @@
// USA. // USA.
// { dg-do compile } // { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 888 } // { dg-error "no matching" "" { target *-*-* } 936 }
// { dg-excess-errors "" } // { dg-excess-errors "" }
#include <vector> #include <vector>