diff options
author | Paolo Carlini <pcarlini@suse.de> | 2007-11-25 18:09:31 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2007-11-25 18:09:31 +0000 |
commit | 2839c1513eda51e3992da102f1af6593231d10b8 (patch) | |
tree | 0f7c79019493b4af335dc844537c9e9ec65d59be /libstdc++-v3/include | |
parent | 674cdfe554096ad0596ef0d88be678a556c3d438 (diff) | |
download | gcc-2839c1513eda51e3992da102f1af6593231d10b8.zip gcc-2839c1513eda51e3992da102f1af6593231d10b8.tar.gz gcc-2839c1513eda51e3992da102f1af6593231d10b8.tar.bz2 |
unordered_map (__unordered_map<>::__unordered_map(__unordered_map&&), [...]): Add in C++0x.
2007-11-25 Paolo Carlini <pcarlini@suse.de>
* include/tr1_impl/unordered_map
(__unordered_map<>::__unordered_map(__unordered_map&&),
__unordered_multimap<>::__unordered_multimap(__unordered_multimap&&),
unordered_map<>::unordered_map(unordered_map&&),
unordered_multimap<>::unordered_multimap(unordered_multimap&&),
unordered_map<>::operator=(unordered_map&&),
unordered_multimap<>::operator=(unordered_multimap&&),
swap(unordered_map<>&&, unordered_map<>&),
swap(unordered_map<>&, unordered_map<>&&),
swap(unordered_multimap<>&&, unordered_multimap<>&),
swap(unordered_multimap<>&, unordered_multimap<>&&)): Add in C++0x.
(swap(unordered_multimap<>&, unordered_multimap<>&),
swap(unordered_multimap<>&, unordered_multimap<>&)): Add.
* include/tr1_impl/unordered_set
(__unordered_set<>::__unordered_set(__unordered_set&&),
__unordered_multiset<>::__unordered_multiset(__unordered_multiset&&),
unordered_set<>::unordered_set(unordered_setp&&),
unordered_multiset<>::unordered_multiset(unordered_multiset&&),
unordered_set<>::operator=(unordered_set&&),
unordered_multiset<>::operator=(unordered_multiset&&),
swap(unordered_set<>&&, unordered_set<>&),
swap(unordered_set<>&, unordered_set<>&&),
swap(unordered_multiset<>&&, unordered_multiset<>&),
swap(unordered_multiset<>&, unordered_multiset<>&&)): Likewise.
(swap(unordered_set<>&, unordered_set<>&),
swap(unordered_multiset<>&, unordered_multiset<>&)): Add.
* include/tr1_impl/hashtable (_Hashtable<>::_Hashtable(_Hashtable&&),
swap(_Hashtable&&)): Add in C++0x.
* testsuite/23_containers/unordered_map/moveable.cc: New.
* testsuite/23_containers/unordered_set/moveable.cc: Likewise.
* testsuite/23_containers/unordered_multimap/moveable.cc: Likewise.
* testsuite/23_containers/unordered_multiset/moveable.cc: Likewise.
From-SVN: r130412
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r-- | libstdc++-v3/include/tr1_impl/hashtable | 40 | ||||
-rw-r--r-- | libstdc++-v3/include/tr1_impl/unordered_map | 76 | ||||
-rw-r--r-- | libstdc++-v3/include/tr1_impl/unordered_set | 76 |
3 files changed, 191 insertions, 1 deletions
diff --git a/libstdc++-v3/include/tr1_impl/hashtable b/libstdc++-v3/include/tr1_impl/hashtable index 093af39..0efe652 100644 --- a/libstdc++-v3/include/tr1_impl/hashtable +++ b/libstdc++-v3/include/tr1_impl/hashtable @@ -217,13 +217,21 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 const allocator_type&); _Hashtable(const _Hashtable&); + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + _Hashtable(_Hashtable&&); +#endif _Hashtable& operator=(const _Hashtable&); - + ~_Hashtable(); +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + void swap(_Hashtable&&); +#else void swap(_Hashtable&); +#endif // Basic container operations iterator @@ -641,6 +649,32 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 } } +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + template<typename _Key, typename _Value, + typename _Allocator, typename _ExtractKey, typename _Equal, + typename _H1, typename _H2, typename _Hash, typename _RehashPolicy, + bool __chc, bool __cit, bool __uk> + _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, + _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: + _Hashtable(_Hashtable&& __ht) + : __detail::_Rehash_base<_RehashPolicy, _Hashtable>(__ht), + __detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Equal, + _H1, _H2, _Hash, __chc>(__ht), + __detail::_Map_base<_Key, _Value, _ExtractKey, __uk, _Hashtable>(__ht), + _M_node_allocator(__ht._M_node_allocator), + _M_bucket_count(__ht._M_bucket_count), + _M_element_count(__ht._M_element_count), + _M_rehash_policy(__ht._M_rehash_policy), + _M_buckets(__ht._M_buckets) + { + size_type __n_bkt = __ht._M_rehash_policy._M_next_bkt(0); + __ht._M_buckets = __ht._M_allocate_buckets(__n_bkt); + __ht._M_bucket_count = __n_bkt; + __ht._M_element_count = 0; + __ht._M_rehash_policy = _RehashPolicy(); + } +#endif + template<typename _Key, typename _Value, typename _Allocator, typename _ExtractKey, typename _Equal, typename _H1, typename _H2, typename _Hash, typename _RehashPolicy, @@ -675,7 +709,11 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 void _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + swap(_Hashtable&& __x) +#else swap(_Hashtable& __x) +#endif { // The only base class with member variables is hash_code_base. We // define _Hash_code_base::_M_swap because different specializations diff --git a/libstdc++-v3/include/tr1_impl/unordered_map b/libstdc++-v3/include/tr1_impl/unordered_map index a362296..5ecd5c0 100644 --- a/libstdc++-v3/include/tr1_impl/unordered_map +++ b/libstdc++-v3/include/tr1_impl/unordered_map @@ -85,6 +85,11 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 __detail::_Default_ranged_hash(), __eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a) { } + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + __unordered_map(__unordered_map&& __x) + : _Base(std::forward<_Base>(__x)) { } +#endif }; template<class _Key, class _Tp, @@ -137,6 +142,11 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 __detail::_Default_ranged_hash(), __eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a) { } + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + __unordered_multimap(__unordered_multimap&& __x) + : _Base(std::forward<_Base>(__x)) { } +#endif }; template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, @@ -189,6 +199,20 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 const allocator_type& __a = allocator_type()) : _Base(__f, __l, __n, __hf, __eql, __a) { } + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + unordered_map(unordered_map&& __x) + : _Base(std::forward<_Base>(__x)) { } + + unordered_map& + operator=(unordered_map&& __x) + { + // NB: DR 675. + this->clear(); + this->swap(__x); + return *this; + } +#endif }; template<class _Key, class _Tp, @@ -223,7 +247,59 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 const allocator_type& __a = allocator_type()) : _Base(__f, __l, __n, __hf, __eql, __a) { } + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + unordered_multimap(unordered_multimap&& __x) + : _Base(std::forward<_Base>(__x)) { } + + unordered_multimap& + operator=(unordered_multimap&& __x) + { + // NB: DR 675. + this->clear(); + this->swap(__x); + return *this; + } +#endif }; + template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> + inline void + swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { __x.swap(__y); } + + template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> + inline void + swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { __x.swap(__y); } + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> + inline void + swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&& __x, + unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { __x.swap(__y); } + + template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> + inline void + swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&& __y) + { __x.swap(__y); } + + template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> + inline void + swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&& __x, + unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y) + { __x.swap(__y); } + + template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> + inline void + swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, + unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&& __y) + { __x.swap(__y); } +#endif + _GLIBCXX_END_NAMESPACE_TR1 } diff --git a/libstdc++-v3/include/tr1_impl/unordered_set b/libstdc++-v3/include/tr1_impl/unordered_set index 2292d36..bdc1575 100644 --- a/libstdc++-v3/include/tr1_impl/unordered_set +++ b/libstdc++-v3/include/tr1_impl/unordered_set @@ -85,6 +85,11 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 __detail::_Default_ranged_hash(), __eql, std::_Identity<_Value>(), __a) { } + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + __unordered_set(__unordered_set&& __x) + : _Base(std::forward<_Base>(__x)) { } +#endif }; template<class _Value, @@ -135,6 +140,11 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 __detail::_Default_ranged_hash(), __eql, std::_Identity<_Value>(), __a) { } + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + __unordered_multiset(__unordered_multiset&& __x) + : _Base(std::forward<_Base>(__x)) { } +#endif }; template<class _Value, class _Hash, class _Pred, class _Alloc, @@ -187,6 +197,20 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 const allocator_type& __a = allocator_type()) : _Base(__f, __l, __n, __hf, __eql, __a) { } + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + unordered_set(unordered_set&& __x) + : _Base(std::forward<_Base>(__x)) { } + + unordered_set& + operator=(unordered_set&& __x) + { + // NB: DR 675. + this->clear(); + this->swap(__x); + return *this; + } +#endif }; template<class _Value, @@ -221,7 +245,59 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 const allocator_type& __a = allocator_type()) : _Base(__f, __l, __n, __hf, __eql, __a) { } + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + unordered_multiset(unordered_multiset&& __x) + : _Base(std::forward<_Base>(__x)) { } + + unordered_multiset& + operator=(unordered_multiset&& __x) + { + // NB: DR 675. + this->clear(); + this->swap(__x); + return *this; + } +#endif }; + template<class _Value, class _Hash, class _Pred, class _Alloc> + inline void + swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, + unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) + { __x.swap(__y); } + + template<class _Value, class _Hash, class _Pred, class _Alloc> + inline void + swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, + unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) + { __x.swap(__y); } + +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + template<class _Value, class _Hash, class _Pred, class _Alloc> + inline void + swap(unordered_set<_Value, _Hash, _Pred, _Alloc>&& __x, + unordered_set<_Value, _Hash, _Pred, _Alloc>& __y) + { __x.swap(__y); } + + template<class _Value, class _Hash, class _Pred, class _Alloc> + inline void + swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, + unordered_set<_Value, _Hash, _Pred, _Alloc>&& __y) + { __x.swap(__y); } + + template<class _Value, class _Hash, class _Pred, class _Alloc> + inline void + swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>&& __x, + unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y) + { __x.swap(__y); } + + template<class _Value, class _Hash, class _Pred, class _Alloc> + inline void + swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, + unordered_multiset<_Value, _Hash, _Pred, _Alloc>&& __y) + { __x.swap(__y); } +#endif + _GLIBCXX_END_NAMESPACE_TR1 } |