]> gcc.gnu.org Git - gcc.git/commitdiff
stl_list.h (list<>::_M_create_node<>(_Args&&...), [...]): Add.
authorPaolo Carlini <pcarlini@suse.de>
Sun, 11 Nov 2007 11:46:10 +0000 (11:46 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sun, 11 Nov 2007 11:46:10 +0000 (11:46 +0000)
2007-11-11  Paolo Carlini  <pcarlini@suse.de>

* include/bits/stl_list.h (list<>::_M_create_node<>(_Args&&...),
_M_insert<>(iterator, _Args&&...), push_front<>(_Args&&...),
push_back<>(_Args&&...)): Add.
(list<>::emplace<>(iterator, _Args&&...), insert(iterator,
value_type&&)): Declare.
(splice(iterator, list&&), splice(iterator, list&&, iterator),
splice(iterator, list&&, iterator, iterator), merge(list&&),
merge(list&&, _StrictWeakOrdering)): Add C++0x signatures.
* include/bits/list.tcc (list<>::emplace<>(iterator, _Args&&...),
insert(iterator, value_type&&)): Define.
* include/debug/list (list<>::emplace<>(iterator, _Args&&...),
insert(iterator, value_type&&)): Add.
(splice(iterator, list&&), splice(iterator, list&&, iterator),
splice(iterator, list&&, iterator, iterator), merge(list&&),
merge(list&&, _StrictWeakOrdering)): Add C++0x signatures, use
_GLIBCXX_MOVE.

From-SVN: r130082

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/list.tcc
libstdc++-v3/include/bits/stl_list.h
libstdc++-v3/include/debug/list
libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc
libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc
libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc
libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc

index c07aae4ecb742fcee32c55fdfdd12f2ada2ba11a..71b9311870e43173f55a5234fbfc39cfc1e7631a 100644 (file)
@@ -1,3 +1,22 @@
+2007-11-11  Paolo Carlini  <pcarlini@suse.de>
+
+       * include/bits/stl_list.h (list<>::_M_create_node<>(_Args&&...),
+       _M_insert<>(iterator, _Args&&...), push_front<>(_Args&&...),
+       push_back<>(_Args&&...)): Add.
+       (list<>::emplace<>(iterator, _Args&&...), insert(iterator,
+       value_type&&)): Declare.
+       (splice(iterator, list&&), splice(iterator, list&&, iterator),
+       splice(iterator, list&&, iterator, iterator), merge(list&&),
+       merge(list&&, _StrictWeakOrdering)): Add C++0x signatures.
+       * include/bits/list.tcc (list<>::emplace<>(iterator, _Args&&...),
+       insert(iterator, value_type&&)): Define.
+       * include/debug/list (list<>::emplace<>(iterator, _Args&&...),
+       insert(iterator, value_type&&)): Add.
+       (splice(iterator, list&&), splice(iterator, list&&, iterator),
+       splice(iterator, list&&, iterator, iterator), merge(list&&),
+       merge(list&&, _StrictWeakOrdering)): Add C++0x signatures, use
+       _GLIBCXX_MOVE.
+
 2007-11-09  Paolo Carlini  <pcarlini@suse.de>
 
        * include/bits/stl_deque.h (deque<>::operator=(deque&&)): Implement
index 3fdc5bbac558502a9fab18a62ed8380a5b2f090a..a7fcfb395ff5ad44bd378e1da46550bf6c176de8 100644 (file)
@@ -80,6 +80,19 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
        }
     }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+  template<typename _Tp, typename _Alloc>
+    template<typename... _Args>
+      typename list<_Tp, _Alloc>::iterator
+      list<_Tp, _Alloc>::
+      emplace(iterator __position, _Args&&... __args)
+      {
+       _Node* __tmp = _M_create_node(std::forward<_Args>(__args)...);
+       __tmp->hook(__position._M_node);
+       return iterator(__tmp);
+      }
+#endif
+
   template<typename _Tp, typename _Alloc>
     typename list<_Tp, _Alloc>::iterator
     list<_Tp, _Alloc>::
@@ -90,6 +103,18 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
       return iterator(__tmp);
     }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+  template<typename _Tp, typename _Alloc>
+    typename list<_Tp, _Alloc>::iterator
+    list<_Tp, _Alloc>::
+    insert(iterator __position, value_type&& __x)
+    {
+      _Node* __tmp = _M_create_node(std::move(__x));
+      __tmp->hook(__position._M_node);
+      return iterator(__tmp);
+    }
+#endif
+
   template<typename _Tp, typename _Alloc>
     typename list<_Tp, _Alloc>::iterator
     list<_Tp, _Alloc>::
@@ -220,7 +245,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
   template<typename _Tp, typename _Alloc>
     void
     list<_Tp, _Alloc>::
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+    merge(list&& __x)
+#else
     merge(list& __x)
+#endif
     {
       // _GLIBCXX_RESOLVE_LIB_DEFECTS
       // 300. list::merge() specification incomplete
@@ -250,7 +279,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
     template <typename _StrictWeakOrdering>
       void
       list<_Tp, _Alloc>::
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      merge(list&& __x, _StrictWeakOrdering __comp)
+#else
       merge(list& __x, _StrictWeakOrdering __comp)
+#endif
       {
        // _GLIBCXX_RESOLVE_LIB_DEFECTS
        // 300. list::merge() specification incomplete
index 41b84f357f4ae97c00bca548e14753406bac88cf..3b143c212e819f3e9fb7dc536052bf18450db845 100644 (file)
@@ -463,6 +463,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
        *  Allocates space for a new node and constructs a copy of @a x in it.
        *  @endif
        */
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
       _Node*
       _M_create_node(const value_type& __x)
       {
@@ -478,6 +479,25 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
          }
        return __p;
       }
+#else
+      template<typename... _Args>
+        _Node*
+        _M_create_node(_Args&&... __args)
+       {
+         _Node* __p = this->_M_get_node();
+         try
+           {
+             _M_get_Tp_allocator().construct(&__p->_M_data,
+                                             std::forward<_Args>(__args)...);
+           }
+         catch(...)
+           {
+             _M_put_node(__p);
+             __throw_exception_again;
+           }
+         return __p;
+       }
+#endif
 
     public:
       // [23.2.2.1] construct/copy/destroy
@@ -823,9 +843,16 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
        *  done in constant time, and does not invalidate iterators and
        *  references.
        */
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
       void
       push_front(const value_type& __x)
       { this->_M_insert(begin(), __x); }
+#else
+      template<typename... _Args>
+        void
+        push_front(_Args&&... __args)
+       { this->_M_insert(begin(), std::forward<_Args>(__args)...); }
+#endif
 
       /**
        *  @brief  Removes first element.
@@ -853,9 +880,16 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
        *  in constant time, and does not invalidate iterators and
        *  references.
        */
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
       void
       push_back(const value_type& __x)
       { this->_M_insert(end(), __x); }
+#else
+      template<typename... _Args>
+        void
+        push_back(_Args&&... __args)
+       { this->_M_insert(end(), std::forward<_Args>(__args)...); }
+#endif
 
       /**
        *  @brief  Removes last element.
@@ -872,6 +906,24 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
       pop_back()
       { this->_M_erase(iterator(this->_M_impl._M_node._M_prev)); }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      /**
+       *  @brief  Constructs object in %list before specified iterator.
+       *  @param  position  A const_iterator into the %list.
+       *  @param  args  Arguments.
+       *  @return  An iterator that points to the inserted data.
+       *
+       *  This function will insert an object of type T constructed
+       *  with T(std::forward<Args>(args)...) before the specified
+       *  location.  Due to the nature of a %list this operation can
+       *  be done in constant time, and does not invalidate iterators
+       *  and references.
+       */
+      template<typename... _Args>
+        iterator
+        emplace(iterator __position, _Args&&... __args);
+#endif
+
       /**
        *  @brief  Inserts given value into %list before specified iterator.
        *  @param  position  An iterator into the %list.
@@ -886,6 +938,22 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
       iterator
       insert(iterator __position, const value_type& __x);
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      /**
+       *  @brief  Inserts given rvalue into %list before specified iterator.
+       *  @param  position  An iterator into the %list.
+       *  @param  x  Data to be inserted.
+       *  @return  An iterator that points to the inserted data.
+       *
+       *  This function will insert a copy of the given rvalue before
+       *  the specified location.  Due to the nature of a %list this
+       *  operation can be done in constant time, and does not
+       *  invalidate iterators and references.
+        */
+      iterator
+      insert(iterator __position, value_type&& __x);
+#endif
+
       /**
        *  @brief  Inserts a number of copies of given data into the %list.
        *  @param  position  An iterator into the %list.
@@ -1021,7 +1089,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
        *  Requires this != @a x.
        */
       void
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      splice(iterator __position, list&& __x)
+#else
       splice(iterator __position, list& __x)
+#endif
       {
        if (!__x.empty())
          {
@@ -1041,7 +1113,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
        *  inserts it into the current list before @a position.
        */
       void
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      splice(iterator __position, list&& __x, iterator __i)
+#else
       splice(iterator __position, list& __x, iterator __i)
+#endif
       {
        iterator __j = __i;
        ++__j;
@@ -1067,7 +1143,13 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
        *  Undefined if @a position is in [first,last).
        */
       void
-      splice(iterator __position, list& __x, iterator __first, iterator __last)
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      splice(iterator __position, list&& __x, iterator __first,
+            iterator __last)
+#else
+      splice(iterator __position, list& __x, iterator __first,
+            iterator __last)
+#endif
       {
        if (__first != __last)
          {
@@ -1146,7 +1228,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
        *  this list precede elements in @a x that are equal.
        */
       void
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      merge(list&& __x);
+#else
       merge(list& __x);
+#endif
 
       /**
        *  @brief  Merge sorted lists according to comparison function.
@@ -1162,7 +1248,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
        */
       template<typename _StrictWeakOrdering>
         void
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+        merge(list&&, _StrictWeakOrdering);
+#else
         merge(list&, _StrictWeakOrdering);
+#endif
 
       /**
        *  @brief  Reverse the elements in list.
@@ -1253,12 +1343,22 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
       { __position._M_node->transfer(__first._M_node, __last._M_node); }
 
       // Inserts new element at position given and with value given.
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
       void
       _M_insert(iterator __position, const value_type& __x)
       {
         _Node* __tmp = _M_create_node(__x);
         __tmp->hook(__position._M_node);
       }
+#else
+     template<typename... _Args>
+       void
+       _M_insert(iterator __position, _Args&&... __args)
+       {
+        _Node* __tmp = _M_create_node(std::forward<_Args>(__args)...);
+        __tmp->hook(__position._M_node);
+       }
+#endif
 
       // Erases element at position given.
       void
index 9e78fc94c523c032ac6972f865551676906b3c08..9b7f33bf4ca0b3225fe7e3de9eb6c25e49b11971 100644 (file)
@@ -301,6 +301,17 @@ namespace __debug
        _Base::pop_back();
       }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      template<typename... _Args>
+        iterator
+        emplace(iterator __position, _Args&&... __args)
+       {
+         __glibcxx_check_insert(__position);
+         return iterator(_Base::emplace(__position.base(),
+                                       std::forward<_Args>(__args)...), this);
+       }
+#endif
+
       iterator
       insert(iterator __position, const _Tp& __x)
       {
@@ -308,6 +319,16 @@ namespace __debug
        return iterator(_Base::insert(__position.base(), __x), this);
       }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      iterator
+      insert(iterator __position, _Tp&& __x)
+      {
+       __glibcxx_check_insert(__position);
+       return iterator(_Base::insert(__position.base(),
+                                     std::move(__x)), this);
+      }
+#endif
+
       void
       insert(iterator __position, size_type __n, const _Tp& __x)
       {
@@ -367,16 +388,24 @@ namespace __debug
 
       // 23.2.2.4 list operations:
       void
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      splice(iterator __position, list&& __x)
+#else
       splice(iterator __position, list& __x)
+#endif
       {
        _GLIBCXX_DEBUG_VERIFY(&__x != this,
                              _M_message(__gnu_debug::__msg_self_splice)
                              ._M_sequence(*this, "this"));
-       this->splice(__position, __x, __x.begin(), __x.end());
+       this->splice(__position, _GLIBCXX_MOVE(__x), __x.begin(), __x.end());
       }
 
       void
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      splice(iterator __position, list&& __x, iterator __i)
+#else
       splice(iterator __position, list& __x, iterator __i)
+#endif
       {
        __glibcxx_check_insert(__position);
 
@@ -393,11 +422,18 @@ namespace __debug
        // _GLIBCXX_RESOLVE_LIB_DEFECTS
        // 250. splicing invalidates iterators
        this->_M_transfer_iter(__i);
-       _Base::splice(__position.base(), __x._M_base(), __i.base());
+       _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()),
+                     __i.base());
       }
 
       void
-      splice(iterator __position, list& __x, iterator __first, iterator __last)
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      splice(iterator __position, list&& __x, iterator __first,
+            iterator __last)
+#else
+      splice(iterator __position, list& __x, iterator __first,
+            iterator __last)
+#endif
       {
        __glibcxx_check_insert(__position);
        __glibcxx_check_valid_range(__first, __last);
@@ -422,8 +458,8 @@ namespace __debug
            this->_M_transfer_iter(__victim);
          }
 
-       _Base::splice(__position.base(), __x._M_base(), __first.base(),
-                     __last.base());
+       _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()),
+                     __first.base(), __last.base());
       }
 
       void
@@ -489,7 +525,11 @@ namespace __debug
        }
 
       void
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      merge(list&& __x)
+#else
       merge(list& __x)
+#endif
       {
        __glibcxx_check_sorted(_Base::begin(), _Base::end());
        __glibcxx_check_sorted(__x.begin().base(), __x.end().base());
@@ -498,12 +538,16 @@ namespace __debug
            iterator __victim = __tmp++;
            __victim._M_attach(&__x);
          }
-       _Base::merge(__x._M_base());
+       _Base::merge(_GLIBCXX_MOVE(__x._M_base()));
       }
 
       template<class _Compare>
         void
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+        merge(list&& __x, _Compare __comp)
+#else
         merge(list& __x, _Compare __comp)
+#endif
         {
          __glibcxx_check_sorted_pred(_Base::begin(), _Base::end(), __comp);
          __glibcxx_check_sorted_pred(__x.begin().base(), __x.end().base(),
@@ -513,7 +557,7 @@ namespace __debug
              iterator __victim = __tmp++;
              __victim._M_attach(&__x);
            }
-         _Base::merge(__x._M_base(), __comp);
+         _Base::merge(_GLIBCXX_MOVE(__x._M_base()), __comp);
        }
 
       void
index 9655db046a8c0fc633ca563e4ffd92fa03cc65aa..853e9300c1ec794418aef0f73cdced9402cf7a3f 100644 (file)
@@ -19,7 +19,7 @@
 // USA.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1236 }
+// { dg-error "no matching" "" { target *-*-* } 1326 }
 // { dg-excess-errors "" }
 
 #include <list>
index 7899588295506db970e80c86bf8afb5a238a68d0..ea84200d9a5987487705104e5cef1b43f82a2f1a 100644 (file)
@@ -19,7 +19,7 @@
 // USA.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1205 }
+// { dg-error "no matching" "" { target *-*-* } 1295 }
 // { dg-excess-errors "" }
 
 #include <list>
index 1624cf83bca2a7f19b4b66082dd24ff9d881143e..8283353bcf70c75f019cbd71040bb14c025f58cd 100644 (file)
@@ -19,7 +19,7 @@
 // USA.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1205 }
+// { dg-error "no matching" "" { target *-*-* } 1295 }
 // { dg-excess-errors "" }
 
 #include <list>
index fddbdacf698c5a4545cbe7c859c77b10b58e7bbb..113b0b860ff6ba321d2128fd9505d0a70f67f419 100644 (file)
@@ -19,7 +19,7 @@
 // USA.
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1205 }
+// { dg-error "no matching" "" { target *-*-* } 1295 }
 // { dg-excess-errors "" }
 
 #include <list>
This page took 0.086308 seconds and 5 git commands to generate.