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
This commit is contained in:
parent
674cdfe554
commit
2839c1513e
@ -1,3 +1,38 @@
|
||||
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.
|
||||
|
||||
2007-11-25 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* include/tr1_impl/array (array<>::_M_check): Remove, not necessary
|
||||
|
@ -218,12 +218,20 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
|
||||
|
||||
_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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -0,0 +1,52 @@
|
||||
// { 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 map (via swap). If the implementation changed
|
||||
// this test may begin to fail.
|
||||
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::unordered_map<int, int> a,b;
|
||||
a[2]=0;
|
||||
b[1]=0;
|
||||
b = std::move(a);
|
||||
VERIFY( b.find(2) != b.end() && a.find(1) == a.end() );
|
||||
|
||||
std::unordered_map<int, int> c(std::move(b));
|
||||
VERIFY( c.find(2) != c.end() );
|
||||
VERIFY( b.find(2) == b.end() );
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
// { 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 multimap (via swap). If the implementation changed
|
||||
// this test may begin to fail.
|
||||
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::unordered_multimap<int, int> a,b;
|
||||
a.insert(std::make_pair(2,0));
|
||||
b.insert(std::make_pair(1,0));
|
||||
b = std::move(a);
|
||||
VERIFY( b.find(2) != b.end() && a.find(1) == a.end() );
|
||||
|
||||
std::unordered_multimap<int, int> c(std::move(b));
|
||||
VERIFY( c.find(2) != c.end() );
|
||||
VERIFY( b.find(2) == b.end() );
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
// { 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 set (via swap). If the implementation changed
|
||||
// this test may begin to fail.
|
||||
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::unordered_multiset<int> a,b;
|
||||
a.insert(2);
|
||||
b.insert(1);
|
||||
b = std::move(a);
|
||||
VERIFY( b.find(2) != b.end() && a.find(1) == a.end() );
|
||||
|
||||
std::unordered_multiset<int> c(std::move(b));
|
||||
VERIFY( c.find(2) != c.end() );
|
||||
VERIFY( b.find(2) == b.end() );
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
// { 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 set (via swap). If the implementation changed
|
||||
// this test may begin to fail.
|
||||
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
|
||||
std::unordered_set<int> a,b;
|
||||
a.insert(2);
|
||||
b.insert(1);
|
||||
b = std::move(a);
|
||||
VERIFY( b.find(2) != b.end() && a.find(1) == a.end() );
|
||||
|
||||
std::unordered_set<int> c(std::move(b));
|
||||
VERIFY( c.find(2) != c.end() );
|
||||
VERIFY( b.find(2) == b.end() );
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user