From 053cc3801ba748081d63afd85a582ebd63b89f0a Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Tue, 16 Oct 2007 15:20:09 +0000 Subject: [PATCH] vstring.h (__versa_string<>:: __versa_string(__versa_string&&), [...]): Add. 2007-10-16 Paolo Carlini * include/ext/vstring.h (__versa_string<>:: __versa_string(__versa_string&&), __versa_string<>::operator=(__versa_string&&, swap(__versa_string<>&&, __versa_string<>&), swap(__versa_string<>(&, __versa_string<>&&)): Add. (__versa_string<>::swap(__versa_string&&)): Adjust for C++0x. * include/ext/sso_string_base.h (__sso_string_base(__sso_string_base&&)): Add. (__sso_string_base()): Use _Alloc_hider(_CharT*). * include/ext/rc_string_base.h (__rc_string_base(__rc_string_base&&)): Add. (__rc_string_base()): Use _Alloc_hider(_CharT*). * include/ext/vstring_util.h (_Alloc_hider::_Alloc_hider(_CharT*)): Add. * testsuite/ext/vstring/moveable.cc: Add. * include/bits/stl_tree.h (_Rb_tree(_Rb_tree&&)): Add. * include/bits/stl_map.h (map<>::map(map&&)): Forward to the latter. * include/bits/stl_set.h (set<>::set(set&&)): Likewise. * include/bits/stl_multimap.h (multimap<>::multimap(multimap&&)): Likewise. * include/bits/stl_multiset.h (multiset<>::multiset(multiset&&)): Likewise. * include/bits/stl_deque.h (_Deque_base<>::_Deque_base(_Deque_base&&)): Add. (deque<>::deque(deque&&)): Forward to the latter. * include/bits/stl_list.h (_List_base<>::_List_base(_List_base&&)): Add. (list<>::list(list&&)): Forward to the latter. * include/bits/stl_vector.h (_Vector_base<>::_Vector_base(_Vector_base&&)): Add. (vector<>::vector(vector&&)): Forward to the latter. * include/bits/stl_bvector.h (_Bvector_base<>::_Bvector_base(_Bvector_base&&)): Add. (vector::vector(vector&&)): Forward to the latter. * testsuite/23_containers/vector/requirements/dr438/assign_neg.cc: Adjust dg-error lines. * 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: Likewise. * 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: Likewise. * 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. From-SVN: r129381 --- libstdc++-v3/ChangeLog | 63 +++++++++++++++++++ libstdc++-v3/include/bits/stl_bvector.h | 16 ++++- libstdc++-v3/include/bits/stl_deque.h | 18 +++++- libstdc++-v3/include/bits/stl_list.h | 12 +++- libstdc++-v3/include/bits/stl_map.h | 4 +- libstdc++-v3/include/bits/stl_multimap.h | 4 +- libstdc++-v3/include/bits/stl_multiset.h | 4 +- libstdc++-v3/include/bits/stl_set.h | 4 +- libstdc++-v3/include/bits/stl_tree.h | 28 +++++++++ libstdc++-v3/include/bits/stl_vector.h | 16 ++++- libstdc++-v3/include/ext/rc_string_base.h | 8 ++- libstdc++-v3/include/ext/sso_string_base.h | 30 ++++++++- libstdc++-v3/include/ext/vstring.h | 49 +++++++++++++++ libstdc++-v3/include/ext/vstring_util.h | 4 ++ .../deque/requirements/dr438/assign_neg.cc | 2 +- .../deque/requirements/dr438/constructor_1_neg.cc | 2 +- .../deque/requirements/dr438/constructor_2_neg.cc | 2 +- .../deque/requirements/dr438/insert_neg.cc | 2 +- .../list/requirements/dr438/assign_neg.cc | 2 +- .../list/requirements/dr438/constructor_1_neg.cc | 2 +- .../list/requirements/dr438/constructor_2_neg.cc | 2 +- .../list/requirements/dr438/insert_neg.cc | 2 +- .../vector/requirements/dr438/assign_neg.cc | 2 +- .../vector/requirements/dr438/constructor_1_neg.cc | 2 +- .../vector/requirements/dr438/constructor_2_neg.cc | 2 +- .../vector/requirements/dr438/insert_neg.cc | 2 +- libstdc++-v3/testsuite/ext/vstring/moveable.cc | 71 ++++++++++++++++++++++ 27 files changed, 321 insertions(+), 34 deletions(-) create mode 100644 libstdc++-v3/testsuite/ext/vstring/moveable.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c72ab47..d3dced6 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,66 @@ +2007-10-16 Paolo Carlini + + * include/ext/vstring.h (__versa_string<>:: + __versa_string(__versa_string&&), + __versa_string<>::operator=(__versa_string&&, + swap(__versa_string<>&&, __versa_string<>&), + swap(__versa_string<>(&, __versa_string<>&&)): Add. + (__versa_string<>::swap(__versa_string&&)): Adjust for C++0x. + * include/ext/sso_string_base.h + (__sso_string_base(__sso_string_base&&)): Add. + (__sso_string_base()): Use _Alloc_hider(_CharT*). + * include/ext/rc_string_base.h (__rc_string_base(__rc_string_base&&)): + Add. + (__rc_string_base()): Use _Alloc_hider(_CharT*). + * include/ext/vstring_util.h (_Alloc_hider::_Alloc_hider(_CharT*)): + Add. + * testsuite/ext/vstring/moveable.cc: Add. + + * include/bits/stl_tree.h (_Rb_tree(_Rb_tree&&)): Add. + * include/bits/stl_map.h (map<>::map(map&&)): Forward to the latter. + * include/bits/stl_set.h (set<>::set(set&&)): Likewise. + * include/bits/stl_multimap.h (multimap<>::multimap(multimap&&)): + Likewise. + * include/bits/stl_multiset.h (multiset<>::multiset(multiset&&)): + Likewise. + * include/bits/stl_deque.h (_Deque_base<>::_Deque_base(_Deque_base&&)): + Add. + (deque<>::deque(deque&&)): Forward to the latter. + * include/bits/stl_list.h (_List_base<>::_List_base(_List_base&&)): + Add. + (list<>::list(list&&)): Forward to the latter. + * include/bits/stl_vector.h + (_Vector_base<>::_Vector_base(_Vector_base&&)): Add. + (vector<>::vector(vector&&)): Forward to the latter. + * include/bits/stl_bvector.h + (_Bvector_base<>::_Bvector_base(_Bvector_base&&)): Add. + (vector::vector(vector&&)): Forward to the latter. + + * testsuite/23_containers/vector/requirements/dr438/assign_neg.cc: + Adjust dg-error lines. + * 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: + Likewise. + * 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: + Likewise. + * 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-15 Paolo Carlini * include/debug/set.h (set<>::cbegin, cend, crbegin, crend): Add. diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h index a704456..cb99b22 100644 --- a/libstdc++-v3/include/bits/stl_bvector.h +++ b/libstdc++-v3/include/bits/stl_bvector.h @@ -416,6 +416,19 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) _Bvector_base(const allocator_type& __a) : _M_impl(__a) { } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + _Bvector_base(_Bvector_base&& __x) + : _M_impl(__x._M_get_Bit_allocator()) + { + this->_M_impl._M_start = __x._M_impl._M_start; + this->_M_impl._M_finish = __x._M_impl._M_finish; + this->_M_impl._M_end_of_storage = __x._M_impl._M_end_of_storage; + __x._M_impl._M_start = _Bit_iterator(); + __x._M_impl._M_finish = _Bit_iterator(); + __x._M_impl._M_end_of_storage = 0; + } +#endif + ~_Bvector_base() { this->_M_deallocate(); } @@ -515,8 +528,7 @@ template #ifdef __GXX_EXPERIMENTAL_CXX0X__ vector(vector&& __x) - : _Base(__x._M_get_Bit_allocator()) - { this->swap(__x); } + : _Base(std::forward<_Base>(__x)) { } #endif template diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h index 41cd231..356cff2 100644 --- a/libstdc++-v3/include/bits/stl_deque.h +++ b/libstdc++-v3/include/bits/stl_deque.h @@ -393,6 +393,21 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) : _M_impl(__a) { } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + _Deque_base(_Deque_base&& __x) + : _M_impl(__x._M_get_Tp_allocator()) + { + _M_initialize_map(0); + if (__x._M_impl._M_map) + { + 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_map, __x._M_impl._M_map); + std::swap(this->_M_impl._M_map_size, __x._M_impl._M_map_size); + } + } +#endif + ~_Deque_base(); protected: @@ -736,8 +751,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * The contents of @a x are a valid, but unspecified %deque. */ deque(deque&& __x) - : _Base(__x._M_get_Tp_allocator(), 0) - { this->swap(__x); } + : _Base(std::forward<_Base>(__x)) { } #endif /** diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h index 7bdeacb..bb8f930 100644 --- a/libstdc++-v3/include/bits/stl_list.h +++ b/libstdc++-v3/include/bits/stl_list.h @@ -351,6 +351,15 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) : _M_impl(__a) { _M_init(); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + _List_base(_List_base&& __x) + : _M_impl(__x._M_get_Node_allocator()) + { + _M_init(); + _List_node_base::swap(this->_M_impl._M_node, __x._M_impl._M_node); + } +#endif + // This is what actually destroys the list. ~_List_base() { _M_clear(); } @@ -521,8 +530,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * The contents of @a x are a valid, but unspecified %list. */ list(list&& __x) - : _Base(__x._M_get_Node_allocator()) - { this->swap(__x); } + : _Base(std::forward<_Base>(__x)) { } #endif /** diff --git a/libstdc++-v3/include/bits/stl_map.h b/libstdc++-v3/include/bits/stl_map.h index 28b396e..bc9d13be 100644 --- a/libstdc++-v3/include/bits/stl_map.h +++ b/libstdc++-v3/include/bits/stl_map.h @@ -186,9 +186,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * 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); } + : _M_t(std::forward<_Rep_type>(__x._M_t)) { } #endif /** diff --git a/libstdc++-v3/include/bits/stl_multimap.h b/libstdc++-v3/include/bits/stl_multimap.h index 1c1883a..a280692 100644 --- a/libstdc++-v3/include/bits/stl_multimap.h +++ b/libstdc++-v3/include/bits/stl_multimap.h @@ -184,9 +184,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * 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); } + : _M_t(std::forward<_Rep_type>(__x._M_t)) { } #endif /** diff --git a/libstdc++-v3/include/bits/stl_multiset.h b/libstdc++-v3/include/bits/stl_multiset.h index 55ec047..60d4d9c 100644 --- a/libstdc++-v3/include/bits/stl_multiset.h +++ b/libstdc++-v3/include/bits/stl_multiset.h @@ -197,9 +197,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * 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); } + : _M_t(std::forward<_Rep_type>(__x._M_t)) { } #endif /** diff --git a/libstdc++-v3/include/bits/stl_set.h b/libstdc++-v3/include/bits/stl_set.h index 1d62848..d260156 100644 --- a/libstdc++-v3/include/bits/stl_set.h +++ b/libstdc++-v3/include/bits/stl_set.h @@ -204,9 +204,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * 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); } + : _M_t(std::forward<_Rep_type>(__x._M_t)) { } #endif /** diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h index 1b9743f..2503c03 100644 --- a/libstdc++-v3/include/bits/stl_tree.h +++ b/libstdc++-v3/include/bits/stl_tree.h @@ -607,6 +607,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std) } } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + _Rb_tree(_Rb_tree&& __x); +#endif + ~_Rb_tree() { _M_erase(_M_begin()); } @@ -819,6 +823,30 @@ _GLIBCXX_BEGIN_NAMESPACE(std) _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __y) { __x.swap(__y); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template + _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: + _Rb_tree(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&& __x) + : _M_impl(__x._M_impl._M_key_compare, __x._M_get_Node_allocator()) + { + if (__x._M_root() != 0) + { + _M_root() = __x._M_root(); + _M_leftmost() = __x._M_leftmost(); + _M_rightmost() = __x._M_rightmost(); + _M_root()->_M_parent = _M_end(); + + __x._M_root() = 0; + __x._M_leftmost() = __x._M_end(); + __x._M_rightmost() = __x._M_end(); + + this->_M_impl._M_node_count = __x._M_impl._M_node_count; + __x._M_impl._M_node_count = 0; + } + } +#endif + template _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index 745ef79..f48fbdb 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -123,6 +123,19 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + _Vector_base(_Vector_base&& __x) + : _M_impl(__x._M_get_Tp_allocator()) + { + this->_M_impl._M_start = __x._M_impl._M_start; + this->_M_impl._M_finish = __x._M_impl._M_finish; + this->_M_impl._M_end_of_storage = __x._M_impl._M_end_of_storage; + __x._M_impl._M_start = 0; + __x._M_impl._M_finish = 0; + __x._M_impl._M_end_of_storage = 0; + } +#endif + ~_Vector_base() { _M_deallocate(this->_M_impl._M_start, this->_M_impl._M_end_of_storage - this->_M_impl._M_start); } @@ -252,8 +265,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * The contents of @a x are a valid, but unspecified %vector. */ vector(vector&& __x) - : _Base(__x._M_get_Tp_allocator()) - { this->swap(__x); } + : _Base(std::forward<_Base>(__x)) { } #endif /** diff --git a/libstdc++-v3/include/ext/rc_string_base.h b/libstdc++-v3/include/ext/rc_string_base.h index 49128aa..81dc7ea 100644 --- a/libstdc++-v3/include/ext/rc_string_base.h +++ b/libstdc++-v3/include/ext/rc_string_base.h @@ -301,12 +301,18 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) { _M_rep()->_M_set_length(__n); } __rc_string_base() - : _M_dataplus(_Alloc(), _S_empty_rep._M_refcopy()) { } + : _M_dataplus(_S_empty_rep._M_refcopy()) { } __rc_string_base(const _Alloc& __a); __rc_string_base(const __rc_string_base& __rcs); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + __rc_string_base(__rc_string_base&& __rcs) + : _M_dataplus(__rcs._M_get_allocator(), __rcs._M_data()) + { __rcs._M_data(_S_empty_rep._M_refcopy()); } +#endif + __rc_string_base(size_type __n, _CharT __c, const _Alloc& __a); template diff --git a/libstdc++-v3/include/ext/sso_string_base.h b/libstdc++-v3/include/ext/sso_string_base.h index 0b576ba..9c8c1bc 100644 --- a/libstdc++-v3/include/ext/sso_string_base.h +++ b/libstdc++-v3/include/ext/sso_string_base.h @@ -175,13 +175,17 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) } __sso_string_base() - : _M_dataplus(_Alloc(), _M_local_data) + : _M_dataplus(_M_local_data) { _M_set_length(0); } __sso_string_base(const _Alloc& __a); __sso_string_base(const __sso_string_base& __rcs); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + __sso_string_base(__sso_string_base&& __rcs); +#endif + __sso_string_base(size_type __n, _CharT __c, const _Alloc& __a); template @@ -336,6 +340,30 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) : _M_dataplus(__rcs._M_get_allocator(), _M_local_data) { _M_construct(__rcs._M_data(), __rcs._M_data() + __rcs._M_length()); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template + __sso_string_base<_CharT, _Traits, _Alloc>:: + __sso_string_base(__sso_string_base&& __rcs) + : _M_dataplus(__rcs._M_get_allocator(), _M_local_data) + { + if (__rcs._M_is_local()) + { + if (__rcs._M_length()) + traits_type::copy(_M_local_data, __rcs._M_local_data, + _S_local_capacity + 1); + } + else + { + _M_data(__rcs._M_data()); + _M_capacity(__rcs._M_allocated_capacity); + } + + _M_length(__rcs._M_length()); + __rcs._M_length(0); + __rcs._M_data(__rcs._M_local_data); + } +#endif + template __sso_string_base<_CharT, _Traits, _Alloc>:: __sso_string_base(size_type __n, _CharT __c, const _Alloc& __a) diff --git a/libstdc++-v3/include/ext/vstring.h b/libstdc++-v3/include/ext/vstring.h index 1f1965e..ae441bf 100644 --- a/libstdc++-v3/include/ext/vstring.h +++ b/libstdc++-v3/include/ext/vstring.h @@ -146,6 +146,18 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) __versa_string(const __versa_string& __str) : __vstring_base(__str) { } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief String move constructor. + * @param str Source string. + * + * The newly-constructed %string contains the exact contents of @a str. + * The contents of @a str are a valid, but unspecified string. + */ + __versa_string(__versa_string&& __str) + : __vstring_base(std::forward<__vstring_base>(__str)) { } +#endif + /** * @brief Construct string as copy of a substring. * @param str Source string. @@ -230,6 +242,23 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) operator=(const __versa_string& __str) { return this->assign(__str); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief String move assignment operator. + * @param str Source string. + * + * The contents of @a str are moved into this string (without copying). + * @a str is a valid, but unspecified string. + */ + __versa_string& + operator=(__versa_string&& __str) + { + if (this != &__str) + this->swap(__str); + return *this; + } +#endif + /** * @brief Copy contents of @a s into this string. * @param s Source null-terminated string. @@ -1279,7 +1308,11 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) * time. */ void +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + swap(__versa_string&& __s) +#else swap(__versa_string& __s) +#endif { this->_M_swap(__s); } // String operations: @@ -2154,6 +2187,22 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs) { __lhs.swap(__rhs); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template class _Base> + inline void + swap(__versa_string<_CharT, _Traits, _Alloc, _Base>&& __lhs, + __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs) + { __lhs.swap(__rhs); } + + template class _Base> + inline void + swap(__versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs, + __versa_string<_CharT, _Traits, _Alloc, _Base>&& __rhs) + { __lhs.swap(__rhs); } +#endif + _GLIBCXX_END_NAMESPACE _GLIBCXX_BEGIN_NAMESPACE(std) diff --git a/libstdc++-v3/include/ext/vstring_util.h b/libstdc++-v3/include/ext/vstring_util.h index ab7cf3c..5725e0a 100644 --- a/libstdc++-v3/include/ext/vstring_util.h +++ b/libstdc++-v3/include/ext/vstring_util.h @@ -46,6 +46,7 @@ #include #include #include +#include _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) @@ -91,6 +92,9 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) struct _Alloc_hider : public _Alloc1 { + _Alloc_hider(_CharT* __ptr) + : _Alloc1(), _M_p(__ptr) { } + _Alloc_hider(const _Alloc1& __a, _CharT* __ptr) : _Alloc1(__a), _M_p(__ptr) { } 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 75b656d..12c510a 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 *-*-* } 1386 } +// { dg-error "no matching" "" { target *-*-* } 1400 } // { dg-excess-errors "" } #include 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 f8cdee3..49c1cfd 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 *-*-* } 1321 } +// { dg-error "no matching" "" { target *-*-* } 1335 } // { dg-excess-errors "" } #include 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 5e652c6..58042e1 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 *-*-* } 1321 } +// { dg-error "no matching" "" { target *-*-* } 1335 } // { dg-excess-errors "" } #include 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 67cb8a6..2d00333 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 *-*-* } 1466 } +// { dg-error "no matching" "" { target *-*-* } 1480 } // { dg-excess-errors "" } #include 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 e47411e..187b751 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 *-*-* } 1226 } +// { dg-error "no matching" "" { target *-*-* } 1234 } // { dg-excess-errors "" } #include 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 69bd5b4..843cb46 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 *-*-* } 1195 } +// { dg-error "no matching" "" { target *-*-* } 1203 } // { dg-excess-errors "" } #include 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 49b4f7c..56a8056 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 *-*-* } 1195 } +// { dg-error "no matching" "" { target *-*-* } 1203 } // { dg-excess-errors "" } #include 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 af21a0c..8c2014d 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 *-*-* } 1195 } +// { dg-error "no matching" "" { target *-*-* } 1203 } // { dg-excess-errors "" } #include 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 33c2c04..c5b20cb 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 *-*-* } 933 } +// { dg-error "no matching" "" { target *-*-* } 945 } // { dg-excess-errors "" } #include 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 846cd04..28e0c4d 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 *-*-* } 873 } +// { dg-error "no matching" "" { target *-*-* } 885 } // { dg-excess-errors "" } #include 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 8dab6ce..717bbc6 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 *-*-* } 873 } +// { dg-error "no matching" "" { target *-*-* } 885 } // { dg-excess-errors "" } #include 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 b97f222..62b331a 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 *-*-* } 974 } +// { dg-error "no matching" "" { target *-*-* } 986 } // { dg-excess-errors "" } #include diff --git a/libstdc++-v3/testsuite/ext/vstring/moveable.cc b/libstdc++-v3/testsuite/ext/vstring/moveable.cc new file mode 100644 index 0000000..7a33145 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/vstring/moveable.cc @@ -0,0 +1,71 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on deque (via swap). If the implementation changed +// this test may begin to fail. + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + __gnu_cxx::__sso_string a,b; + a.push_back('1'); + b = std::move(a); + VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 ); + + __gnu_cxx::__sso_string c(std::move(b)); + VERIFY( c.size() == 1 && c[0] == '1' ); + VERIFY( b.size() == 0 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + __gnu_cxx::__rc_string a,b; + a.push_back('1'); + b = std::move(a); + VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 ); + + __gnu_cxx::__rc_string c(std::move(b)); + VERIFY( c.size() == 1 && c[0] == '1' ); + VERIFY( b.size() == 0 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} -- 2.7.4