OSDN Git Service

2010-03-15 Paolo Carlini <paolo.carlini@oracle.com>
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 15 Mar 2010 17:02:16 +0000 (17:02 +0000)
committerMasaki Muranaka <monaka@monami-software.com>
Sun, 23 May 2010 00:24:27 +0000 (09:24 +0900)
Revert:
2008-11-11  Bob Walters  <bob.s.walters@gmail.com>

* include/bits/forward_list.h: Support non-standard pointer types
(_Fwd_list_node_base): Add _Alloc template parameter.
(_Fwd_list_node<>): Likewise.
(_Fwd_list_iterator<>): Likewise.
(_Fwd_list_const_iterator<>): Likewise.
(_Fwd_list_node_base::_M_next, _M_transfer_after, _M_reverse_after):
Use _Alloc<_Tp>::pointer.
(_Fwd_list_iterator<>::_M_node): Use _Node_base::_Pointer.
(_Fwd_list_base<>::_M_get_node, _M_create_node, _M_create_node,
_M_insert_after, _M_put_node, _M_erase_after): Likewise.
(_Fwd_list_const_iterator<>::_M_node): use _Node_base::_Const_pointer.
(forward_list<>): Use __static_pointer_cast in place of static_cast,
and __const_pointer_cast in place of const_cast.
* include/bits/forward_list.tcc
(_Fwd_list_node<>::_M_sort_after): Using _Pointer typedefs in place
of standard pointers, __static_pointer_cast in place of static_cast.
(_Fwd_list_base<>::_Fwd_list_base, _M_insert_after, _M_erase_after):
Likewise.
(forward_list<>::_M_initialize_dispatch, _M_fill_initialize,
splice_after, remove, remove_if, merge): Likewise.
* testsuite/23_containers/forward_list/ext_pointer/modifiers/1.cc: New.
* testsuite/23_containers/forward_list/ext_pointer/modifiers/2.cc:
Likewise.
* testsuite/23_containers/forward_list/ext_pointer/modifiers/3.cc:
Likewise.
* testsuite/23_containers/forward_list/ext_pointer/modifiers/4.cc:
Likewise.
* testsuite/23_containers/forward_list/ext_pointer/modifiers/5.cc:
Likewise.
* testsuite/23_containers/forward_list/ext_pointer/operations/1.cc:
Likewise.
* testsuite/23_containers/forward_list/ext_pointer/operations/2.cc:
Likewise.
* testsuite/23_containers/forward_list/ext_pointer/operations/3.cc:
Likewise.
* testsuite/23_containers/forward_list/ext_pointer/operations/4.cc:
Likewise.
* testsuite/23_containers/forward_list/ext_pointer/operations/5.cc:
Likewise.
* testsuite/23_containers/forward_list/ext_pointer/operations/6.cc:
Likewise.
* testsuite/23_containers/forward_list/ext_pointer/operations/7.cc:
Likewise.
* testsuite/23_containers/forward_list/ext_pointer/requirements/1.cc:
Likewise.
* testsuite/23_containers/forward_list/ext_pointer/requirements/
explicit_instantiation/1.cc: Likewise.
* testsuite/23_containers/forward_list/ext_pointer/requirements/
explicit_instantiation/3.cc: Likewise.
* testsuite/23_containers/forward_list/ext_pointer/1.cc: Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157462 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 2b2d063..794a0bf 100644 (file)
@@ -1,3 +1,59 @@
+2010-03-15  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       Revert:
+       2008-11-11  Bob Walters  <bob.s.walters@gmail.com>
+
+       * include/bits/forward_list.h: Support non-standard pointer types
+       (_Fwd_list_node_base): Add _Alloc template parameter.
+       (_Fwd_list_node<>): Likewise.
+       (_Fwd_list_iterator<>): Likewise.
+       (_Fwd_list_const_iterator<>): Likewise.
+       (_Fwd_list_node_base::_M_next, _M_transfer_after, _M_reverse_after):
+       Use _Alloc<_Tp>::pointer.
+       (_Fwd_list_iterator<>::_M_node): Use _Node_base::_Pointer.
+       (_Fwd_list_base<>::_M_get_node, _M_create_node, _M_create_node,
+       _M_insert_after, _M_put_node, _M_erase_after): Likewise.
+       (_Fwd_list_const_iterator<>::_M_node): use _Node_base::_Const_pointer.
+       (forward_list<>): Use __static_pointer_cast in place of static_cast,
+       and __const_pointer_cast in place of const_cast.
+       * include/bits/forward_list.tcc
+       (_Fwd_list_node<>::_M_sort_after): Using _Pointer typedefs in place
+       of standard pointers, __static_pointer_cast in place of static_cast.
+       (_Fwd_list_base<>::_Fwd_list_base, _M_insert_after, _M_erase_after):
+       Likewise.
+       (forward_list<>::_M_initialize_dispatch, _M_fill_initialize,
+       splice_after, remove, remove_if, merge): Likewise.
+       * testsuite/23_containers/forward_list/ext_pointer/modifiers/1.cc: New.
+       * testsuite/23_containers/forward_list/ext_pointer/modifiers/2.cc:
+       Likewise.
+       * testsuite/23_containers/forward_list/ext_pointer/modifiers/3.cc:
+       Likewise.
+       * testsuite/23_containers/forward_list/ext_pointer/modifiers/4.cc:
+       Likewise.
+       * testsuite/23_containers/forward_list/ext_pointer/modifiers/5.cc:
+       Likewise.
+       * testsuite/23_containers/forward_list/ext_pointer/operations/1.cc:
+       Likewise.
+       * testsuite/23_containers/forward_list/ext_pointer/operations/2.cc:
+       Likewise.
+       * testsuite/23_containers/forward_list/ext_pointer/operations/3.cc:
+       Likewise.
+       * testsuite/23_containers/forward_list/ext_pointer/operations/4.cc:
+       Likewise.
+       * testsuite/23_containers/forward_list/ext_pointer/operations/5.cc:
+       Likewise.
+       * testsuite/23_containers/forward_list/ext_pointer/operations/6.cc:
+       Likewise.
+       * testsuite/23_containers/forward_list/ext_pointer/operations/7.cc:
+       Likewise.
+       * testsuite/23_containers/forward_list/ext_pointer/requirements/1.cc:
+       Likewise.
+       * testsuite/23_containers/forward_list/ext_pointer/requirements/
+       explicit_instantiation/1.cc: Likewise.
+       * testsuite/23_containers/forward_list/ext_pointer/requirements/
+       explicit_instantiation/3.cc: Likewise.
+       * testsuite/23_containers/forward_list/ext_pointer/1.cc: Likewise.
+
 2010-03-13  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * include/tr1_impl/array (swap(array<>&, array<>&)): Use member swap.
index c0c135c..1dcbefd 100644 (file)
@@ -51,29 +51,28 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     swap(_Fwd_list_node_base& __x, _Fwd_list_node_base& __y)
     { std::swap(__x._M_next, __y._M_next); }
 
-    _Fwd_list_node_base*
-    _M_transfer_after(_Fwd_list_node_base* __begin)
+    void
+    _M_transfer_after(_Fwd_list_node_base* __bbegin)
     {
-      _Fwd_list_node_base* __end = __begin;
-      while (__end && __end->_M_next)
-       __end = __end->_M_next;
-      return _M_transfer_after(__begin, __end);
+      _Fwd_list_node_base* __bend = __bbegin;
+      while (__bend && __bend->_M_next)
+       __bend = __bend->_M_next;
+      _M_transfer_after(__bbegin, __bend);
     }
 
-    _Fwd_list_node_base*
-    _M_transfer_after(_Fwd_list_node_base* __begin,
-                     _Fwd_list_node_base* __end)
+    void
+    _M_transfer_after(_Fwd_list_node_base* __bbegin,
+                     _Fwd_list_node_base* __bend)
     {
-      _Fwd_list_node_base* __keep = __begin->_M_next;
-      if (__end)
+      _Fwd_list_node_base* __keep = __bbegin->_M_next;
+      if (__bend)
        {
-         __begin->_M_next = __end->_M_next;
-         __end->_M_next = _M_next;
+         __bbegin->_M_next = __bend->_M_next;
+         __bend->_M_next = _M_next;
        }
       else
-       __begin->_M_next = 0;
+       __bbegin->_M_next = 0;
       _M_next = __keep;
-      return __end;
     }
 
     void
@@ -139,8 +138,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
 
       pointer
       operator->() const
-      { return std::__addressof(static_cast<_Node*>
-                               (this->_M_node)->_M_value); }
+      { return &static_cast<_Node*>(this->_M_node)->_M_value; }
 
       _Self&
       operator++()
@@ -211,8 +209,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
 
       pointer
       operator->() const
-      { return std::__addressof(static_cast<_Node*>
-                               (this->_M_node)->_M_value); }
+      { return &static_cast<_Node*>(this->_M_node)->_M_value; }
 
       _Self&
       operator++()
@@ -868,8 +865,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        *  @param  pos  An iterator into the %forward_list.
        *  @param  n  Number of elements to be inserted.
        *  @param  val  Data to be inserted.
-       *  @return  An iterator pointing to the last inserted copy of
-       *           @a val or @a pos if @a n == 0.
+       *  @return  pos.
        *
        *  This function will insert a specified number of copies of the
        *  given data after the location specified by @a pos.
@@ -878,15 +874,19 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        *  does not invalidate iterators and references.
        */
       iterator
-      insert_after(const_iterator __pos, size_type __n, const _Tp& __val);
+      insert_after(const_iterator __pos, size_type __n, const _Tp& __val)
+      {
+        forward_list __tmp(__n, __val, this->_M_get_Node_allocator());
+        splice_after(__pos, std::move(__tmp));
+       return iterator(const_cast<_Node_base*>(__pos._M_node));
+      }
 
       /**
        *  @brief  Inserts a range into the %forward_list.
        *  @param  position  An iterator into the %forward_list.
        *  @param  first  An input iterator.
        *  @param  last   An input iterator.
-       *  @return  An iterator pointing to the last inserted element or
-       *           @a pos if @a first == @a last.
+       *  @return  pos.
        *
        *  This function will insert copies of the data in the range [@a
        *  first,@a last) into the %forward_list after the location specified
@@ -898,15 +898,19 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       template<typename _InputIterator>
         iterator
         insert_after(const_iterator __pos,
-                     _InputIterator __first, _InputIterator __last);
+                     _InputIterator __first, _InputIterator __last)
+        {
+          forward_list __tmp(__first, __last, this->_M_get_Node_allocator());
+          splice_after(__pos, std::move(__tmp));
+         return iterator(const_cast<_Node_base*>(__pos._M_node));
+        }
 
       /**
        *  @brief  Inserts the contents of an initializer_list into
        *          %forward_list after the specified iterator.
        *  @param  pos  An iterator into the %forward_list.
        *  @param  il  An initializer_list of value_type.
-       *  @return  An iterator pointing to the last inserted element
-       *           or @a pos if @a il is empty.
+       *  @return  pos.
        *
        *  This function will insert copies of the data in the
        *  initializer_list @a il into the %forward_list before the location
@@ -916,7 +920,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        *  does not invalidate iterators and references.
        */
       iterator
-      insert_after(const_iterator __pos, std::initializer_list<_Tp> __il);
+      insert_after(const_iterator __pos, std::initializer_list<_Tp> __il)
+      {
+        forward_list __tmp(__il, this->_M_get_Node_allocator());
+        splice_after(__pos, std::move(__tmp));
+       return iterator(const_cast<_Node_base*>(__pos._M_node));
+      }
 
       /**
        *  @brief  Removes the element pointed to by the iterator following
@@ -1028,11 +1037,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        *  Requires this != @a x.
        */
       void
-      splice_after(const_iterator __pos, forward_list&& __list)
-      {
-       if (!__list.empty())
-         _M_splice_after(__pos, std::move(__list));
-      }
+      splice_after(const_iterator __pos, forward_list&& __list);
 
       /**
        *  @brief  Insert element from another %forward_list.
@@ -1205,10 +1210,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       // turns out to be the same thing.
       void
       _M_fill_initialize(size_type __n, const value_type& __value);
-
-      // Called by splice_after and insert_after.
-      iterator
-      _M_splice_after(const_iterator __pos, forward_list&& __list);
     };
 
   /**
index 7468a90..e3af42e 100644 (file)
@@ -203,19 +203,22 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     }
 
   template<typename _Tp, typename _Alloc>
-    typename forward_list<_Tp, _Alloc>::iterator
+    void
     forward_list<_Tp, _Alloc>::
-    _M_splice_after(const_iterator __pos, forward_list&& __list)
+    splice_after(const_iterator __pos, forward_list&& __list)
     {
-      _Node_base* __tmp = const_cast<_Node_base*>(__pos._M_node);
-      iterator __before = __list.before_begin();
-      return iterator(__tmp->_M_transfer_after(__before._M_node));
+      if (!__list.empty() && &__list != this)
+        {
+          _Node_base* __tmp = const_cast<_Node_base*>(__pos._M_node);
+          const_iterator __before = __list.cbefore_begin();
+          __tmp->_M_transfer_after(const_cast<_Node_base*>(__before._M_node));
+        }
     }
 
   template<typename _Tp, typename _Alloc>
     void
     forward_list<_Tp, _Alloc>::
-    splice_after(const_iterator __pos, forward_list&&,
+    splice_after(const_iterator __pos, forward_list&& __list,
                  const_iterator __before, const_iterator __last)
     {
       _Node_base* __tmp = const_cast<_Node_base*>(__pos._M_node);
@@ -224,48 +227,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     }
 
   template<typename _Tp, typename _Alloc>
-    typename forward_list<_Tp, _Alloc>::iterator
-    forward_list<_Tp, _Alloc>::
-    insert_after(const_iterator __pos, size_type __n, const _Tp& __val)
-    {
-      if (__n)
-       {
-         forward_list __tmp(__n, __val, this->_M_get_Node_allocator());
-         return _M_splice_after(__pos, std::move(__tmp));
-       }
-      else
-       return iterator(const_cast<_Node_base*>(__pos._M_node));
-    }
-
-  template<typename _Tp, typename _Alloc>
-    template<typename _InputIterator>
-      typename forward_list<_Tp, _Alloc>::iterator
-      forward_list<_Tp, _Alloc>::
-      insert_after(const_iterator __pos,
-                  _InputIterator __first, _InputIterator __last)
-      {
-       forward_list __tmp(__first, __last, this->_M_get_Node_allocator());
-       if (!__tmp.empty())
-         return _M_splice_after(__pos, std::move(__tmp));
-       else
-         return iterator(const_cast<_Node_base*>(__pos._M_node));
-      }
-
-  template<typename _Tp, typename _Alloc>
-    typename forward_list<_Tp, _Alloc>::iterator
-    forward_list<_Tp, _Alloc>::
-    insert_after(const_iterator __pos, std::initializer_list<_Tp> __il)
-    {
-      if (__il.size())
-       {
-         forward_list __tmp(__il, this->_M_get_Node_allocator());
-         return _M_splice_after(__pos, std::move(__tmp));
-       }
-      else
-       return iterator(const_cast<_Node_base*>(__pos._M_node));
-    }
-
-  template<typename _Tp, typename _Alloc>
     void
     forward_list<_Tp, _Alloc>::
     remove(const _Tp& __val)
index 1625e3b..5351a5b 100644 (file)
@@ -1,6 +1,6 @@
 // { dg-do compile }
 // { dg-options "-std=gnu++0x" }
-// { dg-error "no matching" "" { target *-*-* } 1196 }
+// { dg-error "no matching" "" { target *-*-* } 1201 }
 // { dg-excess-errors "" }
 
 // Copyright (C) 2009, 2010 Free Software Foundation
index 5acfcd1..b624ab2 100644 (file)
@@ -1,6 +1,6 @@
 // { dg-do compile }
 // { dg-options "-std=gnu++0x" }
-// { dg-error "no matching" "" { target *-*-* } 1196 }
+// { dg-error "no matching" "" { target *-*-* } 1201 }
 // { dg-excess-errors "" }
 
 // Copyright (C) 2009, 2010 Free Software Foundation
index dcf6908..0a593c8 100644 (file)
@@ -1,6 +1,6 @@
 // { dg-do compile }
 // { dg-options "-std=gnu++0x" }
-// { dg-error "no matching" "" { target *-*-* } 1196 }
+// { dg-error "no matching" "" { target *-*-* } 1201 }
 // { dg-excess-errors "" }
 
 // Copyright (C) 2009, 2010 Free Software Foundation
index 22574fd..4739ce7 100644 (file)
@@ -1,6 +1,6 @@
 // { dg-do compile }
 // { dg-options "-std=gnu++0x" }
-// { dg-error "no matching" "" { target *-*-* } 1196 }
+// { dg-error "no matching" "" { target *-*-* } 1201 }
 // { dg-excess-errors "" }
 
 // Copyright (C) 2009, 2010 Free Software Foundation