OSDN Git Service

2007-10-04 Paolo Carlini <pcarlini@suse.de>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / include / bits / stl_multiset.h
index dab8d6f..6e45b8f 100644 (file)
@@ -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 */