diff options
22 files changed, 680 insertions, 154 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 09c73d6..d02e602 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -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> Benjamin Kosnik <bkoz@redhat.com> diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h index a2a86f2..db9061b 100644 --- a/libstdc++-v3/include/bits/stl_bvector.h +++ b/libstdc++-v3/include/bits/stl_bvector.h @@ -385,6 +385,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) _Bit_iterator _M_start; _Bit_iterator _M_finish; _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) : _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 { 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() { this->_M_deallocate(); } @@ -480,8 +489,11 @@ template<typename _Alloc> using _Base::_M_get_Bit_allocator; public: + vector() + : _Base() { } + explicit - vector(const allocator_type& __a = allocator_type()) + vector(const allocator_type& __a) : _Base(__a) { } explicit @@ -501,6 +513,12 @@ template<typename _Alloc> _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> vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a = allocator_type()) @@ -527,6 +545,15 @@ template<typename _Alloc> return *this; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + vector& + operator=(vector&& __x) + { + this->swap(__x); + return *this; + } +#endif + // assign(), a generalized assignment member function. Two // versions: one that takes a count, and one that takes a range. // The range version is a member template, so we dispatch on whether @@ -681,7 +708,11 @@ template<typename _Alloc> } 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_finish, __x._M_impl._M_finish); diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h index a055396..7a7b86e 100644 --- a/libstdc++-v3/include/bits/stl_deque.h +++ b/libstdc++-v3/include/bits/stl_deque.h @@ -123,13 +123,14 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) _Deque_iterator(_Tp* __x, _Map_pointer __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) : _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 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, const _Tp&, const _Tp*> const_iterator; + _Deque_base() + : _M_impl() + { _M_initialize_map(0); } + _Deque_base(const allocator_type& __a, size_t __num_elements) : _M_impl(__a) { _M_initialize_map(__num_elements); } @@ -406,6 +411,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) iterator _M_start; 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) : _Tp_alloc_type(__a), _M_map(0), _M_map_size(0), _M_start(), _M_finish() @@ -679,14 +689,22 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) /** * @brief Default constructor creates no elements. */ + deque() + : _Base() { } + + /** + * @brief Creates a %deque with no elements. + * @param a An allocator object. + */ explicit - deque(const allocator_type& __a = allocator_type()) - : _Base(__a, 0) {} + deque(const allocator_type& __a) + : _Base(__a, 0) { } /** - * @brief Create a %deque with copies of an exemplar element. + * @brief Creates a %deque with copies of an exemplar element. * @param n The number of elements to initially create. * @param value An element to copy. + * @param a An allocator. * * 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, _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. * @param first An input iterator. * @param last An input iterator. + * @param a An allocator object. * * Create a %deque consisting of copies of the elements from [first, * last). @@ -751,6 +783,22 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) deque& 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. * @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. */ void +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + swap(deque&& __x) +#else swap(deque& __x) +#endif { std::swap(this->_M_impl._M_start, __x._M_impl._M_start); 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) { __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 #endif /* _STL_DEQUE_H */ diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h index dac02c8..2b690eb 100644 --- a/libstdc++-v3/include/bits/stl_list.h +++ b/libstdc++-v3/include/bits/stl_list.h @@ -305,6 +305,10 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) { _List_node_base _M_node; + _List_impl() + : _Node_alloc_type(), _M_node() + { } + _List_impl(const _Node_alloc_type& __a) : _Node_alloc_type(__a), _M_node() { } @@ -339,6 +343,10 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) get_allocator() const { return allocator_type(_M_get_Node_allocator()); } + _List_base() + : _M_impl() + { _M_init(); } + _List_base(const allocator_type& __a) : _M_impl(__a) { _M_init(); } @@ -468,14 +476,22 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) /** * @brief Default constructor creates no elements. */ + list() + : _Base() { } + + /** + * @brief Creates a %list with no elements. + * @param a An allocator object. + */ explicit - list(const allocator_type& __a = allocator_type()) + list(const allocator_type& __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 value An element to copy. + * @param a An allocator object. * * 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()) { _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. * @param first An input iterator. * @param last An input iterator. + * @param a An allocator object. * * Create a %list consisting of copies of the elements from * [@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& 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. * @param n Number of elements to be assigned. @@ -887,7 +933,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * function. */ void +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + swap(list&& __x) +#else swap(list& __x) +#endif { _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) { __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 #endif /* _STL_LIST_H */ - diff --git a/libstdc++-v3/include/bits/stl_map.h b/libstdc++-v3/include/bits/stl_map.h index e1429ef..f4545a0 100644 --- a/libstdc++-v3/include/bits/stl_map.h +++ b/libstdc++-v3/include/bits/stl_map.h @@ -155,26 +155,42 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * @brief Default constructor creates no elements. */ 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 - map(const _Compare& __comp, const allocator_type& __a = allocator_type()) + map(const _Compare& __comp, + const allocator_type& __a = allocator_type()) : _M_t(__comp, __a) { } /** - * @brief Map copy constructor. + * @brief %Map copy constructor. * @param x A %map of identical element and allocator types. * - * The newly-created %map uses a copy of the allocation object used - * by @a x. + * The newly-created %map uses a copy of the allocation object + * used by @a x. */ map(const map& __x) : _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. * @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 * otherwise (where N is distance(first,last)). */ - template <typename _InputIterator> + template<typename _InputIterator> map(_InputIterator __first, _InputIterator __last) - : _M_t(_Compare(), allocator_type()) + : _M_t() { _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 * otherwise (where N is distance(first,last)). */ - template <typename _InputIterator> + template<typename _InputIterator> 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._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. * * 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; } +#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. allocator_type get_allocator() const @@ -434,7 +467,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * * Complexity similar to that of the range constructor. */ - template <typename _InputIterator> + template<typename _InputIterator> void insert(_InputIterator __first, _InputIterator __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. */ void +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + swap(map&& __x) +#else swap(map& __x) +#endif { _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 { 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 - operator== (const map<_K1, _T1, _C1, _A1>&, - 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> + template<typename _K1, typename _T1, typename _C1, typename _A1> friend bool - operator< (const map<_K1, _T1, _C1, _A1>&, - const map<_K1, _T1, _C1, _A1>&); + 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, * 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 operator==(const map<_Key, _Tp, _Compare, _Alloc>& __x, 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. */ - template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> + template<typename _Key, typename _Tp, typename _Compare, typename _Alloc> inline bool operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x, const map<_Key, _Tp, _Compare, _Alloc>& __y) { return __x._M_t < __y._M_t; } /// Based on operator== - template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> + template<typename _Key, typename _Tp, typename _Compare, typename _Alloc> inline bool operator!=(const map<_Key, _Tp, _Compare, _Alloc>& __x, const map<_Key, _Tp, _Compare, _Alloc>& __y) { return !(__x == __y); } /// Based on operator< - template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> + template<typename _Key, typename _Tp, typename _Compare, typename _Alloc> inline bool operator>(const map<_Key, _Tp, _Compare, _Alloc>& __x, const map<_Key, _Tp, _Compare, _Alloc>& __y) { return __y < __x; } /// Based on operator< - template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> + template<typename _Key, typename _Tp, typename _Compare, typename _Alloc> inline bool operator<=(const map<_Key, _Tp, _Compare, _Alloc>& __x, const map<_Key, _Tp, _Compare, _Alloc>& __y) { return !(__y < __x); } /// Based on operator< - template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> + template<typename _Key, typename _Tp, typename _Compare, typename _Alloc> inline bool operator>=(const map<_Key, _Tp, _Compare, _Alloc>& __x, const map<_Key, _Tp, _Compare, _Alloc>& __y) { return !(__x < __y); } /// See std::map::swap(). - template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> + 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); } +#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 #endif /* _STL_MAP_H */ diff --git a/libstdc++-v3/include/bits/stl_multimap.h b/libstdc++-v3/include/bits/stl_multimap.h index 5730854..864f4b2 100644 --- a/libstdc++-v3/include/bits/stl_multimap.h +++ b/libstdc++-v3/include/bits/stl_multimap.h @@ -153,11 +153,12 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * @brief Default constructor creates no elements. */ 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 multimap(const _Compare& __comp, @@ -168,12 +169,26 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * @brief %Multimap copy constructor. * @param x A %multimap of identical element and allocator types. * - * The newly-created %multimap uses a copy of the allocation object used - * by @a x. + * The newly-created %multimap uses a copy of the allocation object + * used by @a x. */ multimap(const multimap& __x) : _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. * @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, * and NlogN otherwise (where N is distance(first,last)). */ - template <typename _InputIterator> + template<typename _InputIterator> multimap(_InputIterator __first, _InputIterator __last) - : _M_t(_Compare(), allocator_type()) - { _M_t._M_insert_equal(__first, __last); } + : _M_t() + { _M_t._M_insert_unique(__first, __last); } /** * @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, * and NlogN otherwise (where N is distance(first,last)). */ - template <typename _InputIterator> + template<typename _InputIterator> multimap(_InputIterator __first, _InputIterator __last, const _Compare& __comp, const allocator_type& __a = allocator_type()) @@ -229,6 +244,22 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) 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. allocator_type get_allocator() const @@ -372,7 +403,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * * Complexity similar to that of the range constructor. */ - template <typename _InputIterator> + template<typename _InputIterator> void insert(_InputIterator __first, _InputIterator __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. */ void +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + swap(multimap&& __x) +#else swap(multimap& __x) +#endif { _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 { 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 - operator== (const multimap<_K1, _T1, _C1, _A1>&, - 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> + template<typename _K1, typename _T1, typename _C1, typename _A1> friend bool - operator< (const multimap<_K1, _T1, _C1, _A1>&, - const multimap<_K1, _T1, _C1, _A1>&); + 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, * 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 operator==(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, 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. */ - template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> + template<typename _Key, typename _Tp, typename _Compare, typename _Alloc> inline bool operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, const multimap<_Key, _Tp, _Compare, _Alloc>& __y) { return __x._M_t < __y._M_t; } /// Based on operator== - template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> + template<typename _Key, typename _Tp, typename _Compare, typename _Alloc> inline bool operator!=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, const multimap<_Key, _Tp, _Compare, _Alloc>& __y) { return !(__x == __y); } /// Based on operator< - template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> + template<typename _Key, typename _Tp, typename _Compare, typename _Alloc> inline bool operator>(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, const multimap<_Key, _Tp, _Compare, _Alloc>& __y) { return __y < __x; } /// Based on operator< - template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> + template<typename _Key, typename _Tp, typename _Compare, typename _Alloc> inline bool operator<=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, const multimap<_Key, _Tp, _Compare, _Alloc>& __y) { return !(__y < __x); } /// Based on operator< - template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> + template<typename _Key, typename _Tp, typename _Compare, typename _Alloc> inline bool operator>=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, const multimap<_Key, _Tp, _Compare, _Alloc>& __y) { return !(__x < __y); } /// See std::multimap::swap(). - template <typename _Key, typename _Tp, typename _Compare, typename _Alloc> + 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); } +#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 #endif /* _STL_MULTIMAP_H */ diff --git a/libstdc++-v3/include/bits/stl_multiset.h b/libstdc++-v3/include/bits/stl_multiset.h index dab8d6f..6e45b8f 100644 --- a/libstdc++-v3/include/bits/stl_multiset.h +++ b/libstdc++-v3/include/bits/stl_multiset.h @@ -86,8 +86,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * called (*_unique versus *_equal, same as the standard). * @endif */ - template <class _Key, class _Compare = std::less<_Key>, - class _Alloc = std::allocator<_Key> > + template <typename _Key, typename _Compare = std::less<_Key>, + typename _Alloc = std::allocator<_Key> > class multiset { // concept requirements @@ -130,13 +130,17 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) typedef typename _Rep_type::difference_type difference_type; // allocation/deallocation - /** * @brief Default constructor creates no elements. */ 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 multiset(const _Compare& __comp, 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, * and NlogN otherwise (where N is distance(first,last)). */ - template <class _InputIterator> + template<typename _InputIterator> multiset(_InputIterator __first, _InputIterator __last) - : _M_t(_Compare(), allocator_type()) + : _M_t() { _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, * and NlogN otherwise (where N is distance(first,last)). */ - template <class _InputIterator> + template<typename _InputIterator> multiset(_InputIterator __first, _InputIterator __last, const _Compare& __comp, 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 * by @a x. */ - multiset(const multiset<_Key,_Compare,_Alloc>& __x) + multiset(const multiset& __x) : _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. * @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, * the allocator object is not copied. */ - multiset<_Key,_Compare,_Alloc>& - operator=(const multiset<_Key,_Compare,_Alloc>& __x) + multiset& + operator=(const multiset& __x) { _M_t = __x._M_t; 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: /// 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. */ 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); } // insert/erase @@ -327,7 +365,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * * Complexity similar to that of the range constructor. */ - template <class _InputIterator> + template<typename _InputIterator> void insert(_InputIterator __first, _InputIterator __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 { return _M_t.equal_range(__x); } - template <class _K1, class _C1, class _A1> + template<typename _K1, typename _C1, typename _A1> friend bool - operator== (const multiset<_K1, _C1, _A1>&, - const multiset<_K1, _C1, _A1>&); + operator==(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 operator< (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 * corresponding elements compare equal. */ - template <class _Key, class _Compare, class _Alloc> + template<typename _Key, typename _Compare, typename _Alloc> inline bool operator==(const multiset<_Key, _Compare, _Alloc>& __x, 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. */ - template <class _Key, class _Compare, class _Alloc> + template<typename _Key, typename _Compare, typename _Alloc> inline bool operator<(const multiset<_Key, _Compare, _Alloc>& __x, const multiset<_Key, _Compare, _Alloc>& __y) { return __x._M_t < __y._M_t; } /// Returns !(x == y). - template <class _Key, class _Compare, class _Alloc> + template<typename _Key, typename _Compare, typename _Alloc> inline bool operator!=(const multiset<_Key, _Compare, _Alloc>& __x, const multiset<_Key, _Compare, _Alloc>& __y) { return !(__x == __y); } /// Returns y < x. - template <class _Key, class _Compare, class _Alloc> + template<typename _Key, typename _Compare, typename _Alloc> inline bool operator>(const multiset<_Key,_Compare,_Alloc>& __x, const multiset<_Key,_Compare,_Alloc>& __y) { return __y < __x; } /// Returns !(y < x) - template <class _Key, class _Compare, class _Alloc> + template<typename _Key, typename _Compare, typename _Alloc> inline bool operator<=(const multiset<_Key, _Compare, _Alloc>& __x, const multiset<_Key, _Compare, _Alloc>& __y) { return !(__y < __x); } /// Returns !(x < y) - template <class _Key, class _Compare, class _Alloc> + template<typename _Key, typename _Compare, typename _Alloc> inline bool operator>=(const multiset<_Key, _Compare, _Alloc>& __x, const multiset<_Key, _Compare, _Alloc>& __y) { return !(__x < __y); } /// See std::multiset::swap(). - template <class _Key, class _Compare, class _Alloc> + template<typename _Key, typename _Compare, typename _Alloc> inline void swap(multiset<_Key, _Compare, _Alloc>& __x, multiset<_Key, _Compare, _Alloc>& __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 #endif /* _STL_MULTISET_H */ diff --git a/libstdc++-v3/include/bits/stl_set.h b/libstdc++-v3/include/bits/stl_set.h index 3bddefc..2b51bfa 100644 --- a/libstdc++-v3/include/bits/stl_set.h +++ b/libstdc++-v3/include/bits/stl_set.h @@ -89,8 +89,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * called (*_unique versus *_equal, same as the standard). * @endif */ - template<class _Key, class _Compare = std::less<_Key>, - class _Alloc = std::allocator<_Key> > + template<typename _Key, typename _Compare = std::less<_Key>, + typename _Alloc = std::allocator<_Key> > class set { // concept requirements @@ -137,20 +137,21 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) //@} // allocation/deallocation - /// Default constructor creates no elements. + /** + * @brief Default constructor creates no elements. + */ set() - : _M_t(_Compare(), allocator_type()) {} + : _M_t() { } /** - * @brief Default constructor creates no elements. - * + * @brief Creates a %set with no elements. * @param comp Comparator to use. - * @param a Allocator to use. + * @param a An allocator object. */ explicit set(const _Compare& __comp, const allocator_type& __a = allocator_type()) - : _M_t(__comp, __a) {} + : _M_t(__comp, __a) { } /** * @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 * otherwise (where N is distance(first,last)). */ - template<class _InputIterator> + template<typename _InputIterator> set(_InputIterator __first, _InputIterator __last) - : _M_t(_Compare(), allocator_type()) + : _M_t() { _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 * otherwise (where N is distance(first,last)). */ - template<class _InputIterator> + template<typename _InputIterator> set(_InputIterator __first, _InputIterator __last, const _Compare& __comp, 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); } /** - * @brief Set copy constructor. + * @brief %Set copy constructor. * @param x A %set of identical element and allocator types. * * The newly-created %set uses a copy of the allocation object used * by @a x. */ - set(const set<_Key,_Compare,_Alloc>& __x) + set(const set& __x) : _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. * * All the elements of @a x are copied, but unlike the copy constructor, * the allocator object is not copied. */ - set<_Key,_Compare,_Alloc>& - operator=(const set<_Key, _Compare, _Alloc>& __x) + set& + operator=(const set& __x) { _M_t = __x._M_t; 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: /// 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. */ 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); } // insert/erase @@ -301,7 +336,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * * Insertion requires logarithmic time. */ - std::pair<iterator,bool> + std::pair<iterator, bool> insert(const value_type& __x) { 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. */ - template<class _InputIterator> + template<typename _InputIterator> void insert(_InputIterator __first, _InputIterator __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); } //@} - template<class _K1, class _C1, class _A1> + template<typename _K1, typename _C1, typename _A1> 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 - 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 * corresponding elements compare equal. */ - template<class _Key, class _Compare, class _Alloc> + template<typename _Key, typename _Compare, typename _Alloc> inline bool operator==(const set<_Key, _Compare, _Alloc>& __x, 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. */ - template<class _Key, class _Compare, class _Alloc> + template<typename _Key, typename _Compare, typename _Alloc> inline bool operator<(const set<_Key, _Compare, _Alloc>& __x, const set<_Key, _Compare, _Alloc>& __y) { return __x._M_t < __y._M_t; } /// Returns !(x == y). - template<class _Key, class _Compare, class _Alloc> + template<typename _Key, typename _Compare, typename _Alloc> inline bool operator!=(const set<_Key, _Compare, _Alloc>& __x, const set<_Key, _Compare, _Alloc>& __y) { return !(__x == __y); } /// Returns y < x. - template<class _Key, class _Compare, class _Alloc> + template<typename _Key, typename _Compare, typename _Alloc> inline bool operator>(const set<_Key, _Compare, _Alloc>& __x, const set<_Key, _Compare, _Alloc>& __y) { return __y < __x; } /// Returns !(y < x) - template<class _Key, class _Compare, class _Alloc> + template<typename _Key, typename _Compare, typename _Alloc> inline bool operator<=(const set<_Key, _Compare, _Alloc>& __x, const set<_Key, _Compare, _Alloc>& __y) { return !(__y < __x); } /// Returns !(x < y) - template<class _Key, class _Compare, class _Alloc> + template<typename _Key, typename _Compare, typename _Alloc> inline bool operator>=(const set<_Key, _Compare, _Alloc>& __x, const set<_Key, _Compare, _Alloc>& __y) { return !(__x < __y); } /// See std::set::swap(). - template<class _Key, class _Compare, class _Alloc> + template<typename _Key, typename _Compare, typename _Alloc> inline void swap(set<_Key, _Compare, _Alloc>& __x, set<_Key, _Compare, _Alloc>& __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 #endif /* _STL_SET_H */ diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h index 8437c9a..1b9743f 100644 --- a/libstdc++-v3/include/bits/stl_tree.h +++ b/libstdc++-v3/include/bits/stl_tree.h @@ -400,16 +400,25 @@ _GLIBCXX_BEGIN_NAMESPACE(std) _Rb_tree_node_base _M_header; size_type _M_node_count; // Keeps track of size of tree. - _Rb_tree_impl(const _Node_allocator& __a = _Node_allocator(), - const _Key_compare& __comp = _Key_compare()) - : _Node_allocator(__a), _M_key_compare(__comp), _M_header(), + _Rb_tree_impl() + : _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(), + _M_node_count(0) + { _M_initialize(); } + + private: + void + _M_initialize() { this->_M_header._M_color = _S_red; this->_M_header._M_parent = 0; this->_M_header._M_left = &this->_M_header; this->_M_header._M_right = &this->_M_header; - } + } }; // Specialization for _Comparison types that are not capable of @@ -421,16 +430,25 @@ _GLIBCXX_BEGIN_NAMESPACE(std) _Rb_tree_node_base _M_header; size_type _M_node_count; // Keeps track of size of tree. - _Rb_tree_impl(const _Node_allocator& __a = _Node_allocator(), - const _Key_compare& __comp = _Key_compare()) + _Rb_tree_impl() + : _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(), _M_node_count(0) - { + { _M_initialize(); } + + private: + void + _M_initialize() + { this->_M_header._M_color = _S_red; this->_M_header._M_parent = 0; this->_M_header._M_left = &this->_M_header; this->_M_header._M_right = &this->_M_header; - } + } }; _Rb_tree_impl<_Compare> _M_impl; @@ -571,19 +589,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std) public: // allocation/deallocation - _Rb_tree() - { } + _Rb_tree() { } - _Rb_tree(const _Compare& __comp) - : _M_impl(allocator_type(), __comp) - { } + _Rb_tree(const _Compare& __comp, + const allocator_type& __a = allocator_type()) + : _M_impl(__comp, __a) { } - _Rb_tree(const _Compare& __comp, const allocator_type& __a) - : _M_impl(__a, __comp) - { } - - _Rb_tree(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x) - : _M_impl(__x._M_get_Node_allocator(), __x._M_impl._M_key_compare) + _Rb_tree(const _Rb_tree& __x) + : _M_impl(__x._M_impl._M_key_compare, __x._M_get_Node_allocator()) { if (__x._M_root() != 0) { @@ -597,8 +610,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ~_Rb_tree() { _M_erase(_M_begin()); } - _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& - operator=(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x); + _Rb_tree& + operator=(const _Rb_tree& __x); // Accessors. _Compare @@ -659,7 +672,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return get_allocator().max_size(); } 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. pair<iterator, bool> @@ -1060,7 +1077,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) typename _Compare, typename _Alloc> void _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) +#endif { if (_M_root() == 0) { diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index 93db413..2f3384d 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -84,6 +84,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) _Tp* _M_start; _Tp* _M_finish; _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) : _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 { return allocator_type(_M_get_Tp_allocator()); } + _Vector_base() + : _M_impl() { } + _Vector_base(const allocator_type& __a) - : _M_impl(__a) - { } + : _M_impl(__a) { } _Vector_base(size_t __n, const allocator_type& __a) : _M_impl(__a) @@ -194,15 +201,22 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) /** * @brief Default constructor creates no elements. */ + vector() + : _Base() { } + + /** + * @brief Creates a %vector with no elements. + * @param a An allocator object. + */ explicit - vector(const allocator_type& __a = allocator_type()) - : _Base(__a) - { } + vector(const allocator_type& __a) + : _Base(__a) { } /** - * @brief Create a %vector with copies of an exemplar element. + * @brief Creates a %vector with copies of an exemplar element. * @param n The number of elements to initially create. * @param value An element to copy. + * @param a An allocator. * * 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()); } +#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. * @param first An input iterator. * @param last An input iterator. + * @param a An allocator. * * Create a %vector consisting of copies of the elements from * [first,last). @@ -275,6 +303,22 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) vector& 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. * @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. */ void +#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_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) { __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 #endif /* _STL_VECTOR_H */ diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc index 0c47da0..8fde473 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1297 } +// { dg-error "no matching" "" { target *-*-* } 1349 } // { dg-excess-errors "" } #include <deque> diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc index fc0beff..3124e19 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1232 } +// { dg-error "no matching" "" { target *-*-* } 1284 } // { dg-excess-errors "" } #include <deque> diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc index 403f647..1f6115c 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1232 } +// { dg-error "no matching" "" { target *-*-* } 1284 } // { dg-excess-errors "" } #include <deque> diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc index 2e2abc5..9d63659 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1377 } +// { dg-error "no matching" "" { target *-*-* } 1429 } // { dg-excess-errors "" } #include <deque> diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc index 4ad1127..ccabf38 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1138 } +// { dg-error "no matching" "" { target *-*-* } 1188 } // { dg-excess-errors "" } #include <list> diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc index 5df6fc8..0711505 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1107 } +// { dg-error "no matching" "" { target *-*-* } 1157 } // { dg-excess-errors "" } #include <list> diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc index 6783727..1e02ca8 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1107 } +// { dg-error "no matching" "" { target *-*-* } 1157 } // { dg-excess-errors "" } #include <list> diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc index c8f2026..04b3c2b 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1107 } +// { dg-error "no matching" "" { target *-*-* } 1157 } // { dg-excess-errors "" } #include <list> diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc index 609511f..4239d4d 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 847 } +// { dg-error "no matching" "" { target *-*-* } 895 } // { dg-excess-errors "" } #include <vector> diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc index 12aa0ae..7faf1e2 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 787 } +// { dg-error "no matching" "" { target *-*-* } 835 } // { dg-excess-errors "" } #include <vector> diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc index 1dd8d30..66c0206 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 787 } +// { dg-error "no matching" "" { target *-*-* } 835 } // { dg-excess-errors "" } #include <vector> diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc index 707776d..6aae607 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 888 } +// { dg-error "no matching" "" { target *-*-* } 936 } // { dg-excess-errors "" } #include <vector> |