]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
unordered_map (__unordered_map<>::__unordered_map(__unordered_map&&), [...]): Add...
authorPaolo Carlini <pcarlini@suse.de>
Sun, 25 Nov 2007 18:09:31 +0000 (18:09 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sun, 25 Nov 2007 18:09:31 +0000 (18:09 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/include/tr1_impl/hashtable
libstdc++-v3/include/tr1_impl/unordered_map
libstdc++-v3/include/tr1_impl/unordered_set
libstdc++-v3/testsuite/23_containers/unordered_map/moveable.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_multimap/moveable.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_multiset/moveable.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_set/moveable.cc [new file with mode: 0644]

index 0688b26524a2ec7f4edd0843d86562a604f637ab..fe86a8046909eadffc22a0fce940b4d006a1d503 100644 (file)
@@ -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
index 093af39fef3c1358695db567ade7c56d966e7e74..0efe6520a281e08d458cf07fc38fd9f84da95511 100644 (file)
@@ -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
index a3622960108a854c0548708ea51e841d6a871f13..5ecd5c0a9983b205b347f21cf40aef2000a7b134 100644 (file)
@@ -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
 }
index 2292d365979e2600dff67dc5649e5aa90ab438d2..bdc1575a445b53a6b54cc414f60e64b1cbe6dcdc 100644 (file)
@@ -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
 }
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/moveable.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/moveable.cc
new file mode 100644 (file)
index 0000000..4032a74
--- /dev/null
@@ -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;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/moveable.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/moveable.cc
new file mode 100644 (file)
index 0000000..96e420b
--- /dev/null
@@ -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;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/moveable.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/moveable.cc
new file mode 100644 (file)
index 0000000..baa35a9
--- /dev/null
@@ -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;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/moveable.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/moveable.cc
new file mode 100644 (file)
index 0000000..a67e942
--- /dev/null
@@ -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;
+}