OSDN Git Service

Licensing changes to GPLv3 resp. GPLv3 with GCC Runtime Exception.
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / include / debug / multiset.h
index 50d9a16..3e4ee86 100644 (file)
@@ -1,12 +1,12 @@
 // Debugging multiset implementation -*- C++ -*-
 
-// Copyright (C) 2003, 2004, 2005
+// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009
 // 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)
+// Free Software Foundation; either version 3, or (at your option)
 // any later version.
 
 // This library is distributed in the hope that it will be useful,
 // 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
 
-// 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.
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// <http://www.gnu.org/licenses/>.
+
+/** @file debug/multiset.h
+ *  This file is a GNU debug extension to the Standard C++ Library.
+ */
 
 #ifndef _GLIBCXX_DEBUG_MULTISET_H
 #define _GLIBCXX_DEBUG_MULTISET_H 1
@@ -42,10 +41,10 @@ namespace __debug
   template<typename _Key, typename _Compare = std::less<_Key>,
           typename _Allocator = std::allocator<_Key> >
     class multiset
-    : public _GLIBCXX_STD::multiset<_Key, _Compare, _Allocator>,
+    : public _GLIBCXX_STD_D::multiset<_Key, _Compare, _Allocator>,
       public __gnu_debug::_Safe_sequence<multiset<_Key, _Compare, _Allocator> >
     {
-      typedef _GLIBCXX_STD::multiset<_Key, _Compare, _Allocator> _Base;
+      typedef _GLIBCXX_STD_D::multiset<_Key, _Compare, _Allocator> _Base;
       typedef __gnu_debug::_Safe_sequence<multiset> _Safe_base;
 
     public:
@@ -82,21 +81,52 @@ namespace __debug
        : _Base(__gnu_debug::__check_valid_range(__first, __last), __last,
                __comp, __a) { }
 
-      multiset(const multiset<_Key,_Compare,_Allocator>& __x)
+      multiset(const multiset& __x)
+      : _Base(__x), _Safe_base() { }
+
+      multiset(const _Base& __x)
       : _Base(__x), _Safe_base() { }
 
-      multiset(const _Base& __x) : _Base(__x), _Safe_base() { }
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      multiset(multiset&& __x)
+      : _Base(std::forward<multiset>(__x)), _Safe_base()
+      { this->_M_swap(__x); }
+
+      multiset(initializer_list<value_type> __l,
+              const _Compare& __comp = _Compare(),
+              const allocator_type& __a = allocator_type())
+      : _Base(__l, __comp, __a), _Safe_base() { }
+#endif
 
       ~multiset() { }
 
-      multiset<_Key,_Compare,_Allocator>&
-      operator=(const multiset<_Key,_Compare,_Allocator>& __x)
+      multiset&
+      operator=(const multiset& __x)
       {
        *static_cast<_Base*>(this) = __x;
        this->_M_invalidate_all();
        return *this;
       }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      multiset&
+      operator=(multiset&& __x)
+      {
+        // NB: DR 675.
+       clear();
+       swap(__x);
+       return *this;
+      }
+
+      multiset&
+      operator=(initializer_list<value_type> __l)
+      {
+       this->clear();
+       this->insert(__l);
+       return *this;
+      }
+#endif
+
       using _Base::get_allocator;
 
       // iterators:
@@ -132,6 +162,24 @@ namespace __debug
       rend() const
       { return const_reverse_iterator(begin()); }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      const_iterator
+      cbegin() const
+      { return const_iterator(_Base::begin(), this); }
+
+      const_iterator
+      cend() const
+      { return const_iterator(_Base::end(), this); }
+
+      const_reverse_iterator
+      crbegin() const
+      { return const_reverse_iterator(end()); }
+
+      const_reverse_iterator
+      crend() const
+      { return const_reverse_iterator(begin()); }
+#endif
+
       // capacity:
       using _Base::empty;
       using _Base::size;
@@ -157,6 +205,12 @@ namespace __debug
        _Base::insert(__first, __last);
       }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      void
+      insert(initializer_list<value_type> __l)
+      { _Base::insert(__l); }
+#endif
+
       void
       erase(iterator __position)
       {
@@ -191,7 +245,11 @@ namespace __debug
       }
 
       void
-      swap(multiset<_Key,_Compare,_Allocator>& __x)
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      swap(multiset&& __x)
+#else
+      swap(multiset& __x)
+#endif
       {
        _Base::swap(__x);
        this->_M_swap(__x);
@@ -278,45 +336,60 @@ namespace __debug
 
   template<typename _Key, typename _Compare, typename _Allocator>
     inline bool
-    operator==(const multiset<_Key,_Compare,_Allocator>& __lhs,
-              const multiset<_Key,_Compare,_Allocator>& __rhs)
+    operator==(const multiset<_Key, _Compare, _Allocator>& __lhs,
+              const multiset<_Key, _Compare, _Allocator>& __rhs)
     { return __lhs._M_base() == __rhs._M_base(); }
 
   template<typename _Key, typename _Compare, typename _Allocator>
     inline bool
-    operator!=(const multiset<_Key,_Compare,_Allocator>& __lhs,
-              const multiset<_Key,_Compare,_Allocator>& __rhs)
+    operator!=(const multiset<_Key, _Compare, _Allocator>& __lhs,
+              const multiset<_Key, _Compare, _Allocator>& __rhs)
     { return __lhs._M_base() != __rhs._M_base(); }
 
   template<typename _Key, typename _Compare, typename _Allocator>
     inline bool
-    operator<(const multiset<_Key,_Compare,_Allocator>& __lhs,
-             const multiset<_Key,_Compare,_Allocator>& __rhs)
+    operator<(const multiset<_Key, _Compare, _Allocator>& __lhs,
+             const multiset<_Key, _Compare, _Allocator>& __rhs)
     { return __lhs._M_base() < __rhs._M_base(); }
 
   template<typename _Key, typename _Compare, typename _Allocator>
     inline bool
-    operator<=(const multiset<_Key,_Compare,_Allocator>& __lhs,
-              const multiset<_Key,_Compare,_Allocator>& __rhs)
+    operator<=(const multiset<_Key, _Compare, _Allocator>& __lhs,
+              const multiset<_Key, _Compare, _Allocator>& __rhs)
     { return __lhs._M_base() <= __rhs._M_base(); }
 
   template<typename _Key, typename _Compare, typename _Allocator>
     inline bool
-    operator>=(const multiset<_Key,_Compare,_Allocator>& __lhs,
-              const multiset<_Key,_Compare,_Allocator>& __rhs)
+    operator>=(const multiset<_Key, _Compare, _Allocator>& __lhs,
+              const multiset<_Key, _Compare, _Allocator>& __rhs)
     { return __lhs._M_base() >= __rhs._M_base(); }
 
   template<typename _Key, typename _Compare, typename _Allocator>
     inline bool
-    operator>(const multiset<_Key,_Compare,_Allocator>& __lhs,
-             const multiset<_Key,_Compare,_Allocator>& __rhs)
+    operator>(const multiset<_Key, _Compare, _Allocator>& __lhs,
+             const multiset<_Key, _Compare, _Allocator>& __rhs)
     { return __lhs._M_base() > __rhs._M_base(); }
 
   template<typename _Key, typename _Compare, typename _Allocator>
     void
-    swap(multiset<_Key,_Compare,_Allocator>& __x,
-        multiset<_Key,_Compare,_Allocator>& __y)
+    swap(multiset<_Key, _Compare, _Allocator>& __x,
+        multiset<_Key, _Compare, _Allocator>& __y)
     { return __x.swap(__y); }
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+  template<typename _Key, typename _Compare, typename _Allocator>
+    void
+    swap(multiset<_Key, _Compare, _Allocator>&& __x,
+        multiset<_Key, _Compare, _Allocator>& __y)
+    { return __x.swap(__y); }
+
+  template<typename _Key, typename _Compare, typename _Allocator>
+    void
+    swap(multiset<_Key, _Compare, _Allocator>& __x,
+        multiset<_Key, _Compare, _Allocator>&& __y)
+    { return __x.swap(__y); }
+#endif
+
 } // namespace __debug
 } // namespace std