OSDN Git Service

2008-11-11 Bob Walters <bob.s.walters@gmail.com>
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 11 Nov 2008 12:16:57 +0000 (12:16 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 11 Nov 2008 12:16:57 +0000 (12:16 +0000)
* 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@141765 138bc75d-0d04-0410-961f-82ee72b054a4

19 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/forward_list.h
libstdc++-v3/include/bits/forward_list.tcc
libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/modifiers/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/modifiers/2.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/modifiers/3.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/modifiers/4.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/modifiers/5.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/2.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/3.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/4.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/5.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/6.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/7.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/requirements/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/requirements/explicit_instantiation/1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/requirements/explicit_instantiation/3.cc [new file with mode: 0644]

index 48d3cad..3b91845 100644 (file)
@@ -1,3 +1,56 @@
+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.
+
 2008-11-11  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * include/ext/extptr_allocator.h: Minor tweaks.
index 60b187f..cb73978 100644 (file)
 
 #include <memory>
 #include <initializer_list>
+#include <ext/cast.h>
 
 _GLIBCXX_BEGIN_NAMESPACE(std)
 
+  using __gnu_cxx::__static_pointer_cast;
+  using __gnu_cxx::__const_pointer_cast;
+
   /**
    *  @brief  A helper basic node class for @forward_list.
    *          This is just a linked list with nothing inside it.
    *          There are purely list shuffling utility methods here.
    */
-  struct _Fwd_list_node_base
-  {
-    _Fwd_list_node_base() : _M_next(0) { }
-
-    _Fwd_list_node_base* _M_next;
-
-    static void
-    swap(_Fwd_list_node_base& __x, _Fwd_list_node_base& __y)
-    { std::swap(__x._M_next, __y._M_next); }
-
-    void
-    _M_transfer_after(_Fwd_list_node_base* __bbegin,
-                      _Fwd_list_node_base* __bend)
-    {
-      _Fwd_list_node_base* __keep = __bbegin->_M_next;
-      if (__bend)
-        {
-          __bbegin->_M_next = __bend->_M_next;
-          __bend->_M_next = this->_M_next;
-        }
-      else
-        __bbegin->_M_next = 0;
-      this->_M_next = __keep;
-    }
-
-    void
-    _M_transfer_after(_Fwd_list_node_base* __bbegin)
+  template<typename _Alloc>
+    struct _Fwd_list_node_base
     {
-      _Fwd_list_node_base* __bend = __bbegin;
-      while (__bend && __bend->_M_next)
-        __bend = __bend->_M_next;
-      _M_transfer_after(__bbegin, __bend);
-    }
-
-    void
-    _M_reverse_after()
-    {
-      _Fwd_list_node_base* __tail = this->_M_next;
-      if (!__tail)
-        return;
-      while (_Fwd_list_node_base* __temp = __tail->_M_next)
-        {
-          _Fwd_list_node_base* __keep = this->_M_next;
-          this->_M_next = __temp;
-          __tail->_M_next = __temp->_M_next;
-          this->_M_next->_M_next = __keep;
-        }
-    }
-  };
+      // The type allocated by _Alloc cannot be this type, so we rebind
+      typedef typename _Alloc::template rebind<_Fwd_list_node_base<_Alloc> >
+        ::other::pointer        _Pointer;
+      typedef typename _Alloc::template rebind<_Fwd_list_node_base<_Alloc> >
+        ::other::const_pointer  _Const_pointer;
+  
+      _Pointer _M_next;
+  
+      _Fwd_list_node_base() : _M_next(0) { }
+  
+      static void
+      swap(_Fwd_list_node_base& __x, _Fwd_list_node_base& __y)
+      { std::swap(__x._M_next, __y._M_next); }
+  
+      void
+      _M_transfer_after(_Pointer __bbegin, _Pointer __bend)
+      { 
+        _Pointer __keep = __bbegin->_M_next;
+        if (__bend)
+          {
+            __bbegin->_M_next = __bend->_M_next;
+            __bend->_M_next = this->_M_next;
+          }
+        else
+          __bbegin->_M_next = 0;
+        this->_M_next = __keep;
+      }
+  
+      void
+      _M_transfer_after(_Pointer __bbegin)
+      {
+        _Pointer __bend = __bbegin;
+        while (__bend && __bend->_M_next)
+          __bend = __bend->_M_next;
+        _M_transfer_after(__bbegin, __bend);
+      }
+  
+      void
+      _M_reverse_after()
+      { 
+        _Pointer __tail = this->_M_next;
+        if (!__tail)
+          return;
+        while (_Pointer __temp = __tail->_M_next)
+          {
+            _Pointer __keep = this->_M_next;
+            this->_M_next = __temp;
+            __tail->_M_next = __temp->_M_next;
+            this->_M_next->_M_next = __keep;
+          }
+      }    
+    };
 
   /**
    *  @brief  A helper node class for @forward_list.
    *          This is just a linked list with a data value in each node.
    *          There is a sorting utility method.
    */
-  template<typename _Tp>
-    struct _Fwd_list_node : public _Fwd_list_node_base
+  template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
+    struct _Fwd_list_node : public _Fwd_list_node_base<_Alloc>
     {
+      typedef typename _Alloc::template rebind<_Fwd_list_node<_Tp, _Alloc> >
+        ::other::pointer        _Pointer;
+
       template<typename... _Args>
         _Fwd_list_node(_Args&&... __args)
-        : _Fwd_list_node_base(), _M_value(std::forward<_Args>(__args)...) { }
+        : _Fwd_list_node_base<_Alloc>(), 
+          _M_value(std::forward<_Args>(__args)...) { }
 
       template<typename _Comp>
         void
@@ -124,30 +138,32 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
    * 
    *   All the functions are op overloads.
    */
-  template<typename _Tp>
+  template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
     struct _Fwd_list_iterator
     {
-      typedef _Fwd_list_iterator<_Tp>           _Self;
-      typedef _Fwd_list_node<_Tp>               _Node;
+      typedef _Fwd_list_iterator<_Tp, _Alloc>   _Self;
+      typedef _Fwd_list_node<_Tp, _Alloc>       _Node;
+      typedef _Fwd_list_node_base<_Alloc>       _Node_base;
 
       typedef _Tp                               value_type;
-      typedef _Tp*                              pointer;
-      typedef _Tp&                              reference;
-      typedef ptrdiff_t                         difference_type;
+      typedef typename _Alloc::pointer          pointer;
+      typedef typename _Alloc::reference        reference;
+      typedef typename _Alloc::difference_type  difference_type;
       typedef std::forward_iterator_tag         iterator_category;
 
       _Fwd_list_iterator() : _M_node() { }
 
       explicit
-      _Fwd_list_iterator(_Fwd_list_node_base* __n) : _M_node(__n) { }
+      _Fwd_list_iterator(typename _Node_base::_Pointer __n) 
+      : _M_node(__n) { }
 
       reference
       operator*() const
-      { return static_cast<_Node*>(this->_M_node)->_M_value; }
+      { return __static_pointer_cast<_Node*>(this->_M_node)->_M_value; }
 
       pointer
       operator->() const
-      { return &static_cast<_Node*>(this->_M_node)->_M_value; }
+      { return &__static_pointer_cast<_Node*>(this->_M_node)->_M_value; }
 
       _Self&
       operator++()
@@ -181,7 +197,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
           return _Fwd_list_iterator(0);
       }
 
-      _Fwd_list_node_base* _M_node;
+      typename _Node_base::_Pointer _M_node;
     };
 
   /**
@@ -189,23 +205,24 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
    * 
    *   All the functions are op overloads.
    */
-  template<typename _Tp>
+  template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
     struct _Fwd_list_const_iterator
     {
-      typedef _Fwd_list_const_iterator<_Tp>     _Self;
-      typedef const _Fwd_list_node<_Tp>         _Node;
-      typedef _Fwd_list_iterator<_Tp>           iterator;
+      typedef _Fwd_list_const_iterator<_Tp, _Alloc>   _Self;
+      typedef const _Fwd_list_node<_Tp, _Alloc>       _Node;
+      typedef const _Fwd_list_node_base<_Alloc>       _Node_base;
+      typedef _Fwd_list_iterator<_Tp, _Alloc>         iterator;
 
-      typedef _Tp                               value_type;
-      typedef const _Tp*                        pointer;
-      typedef const _Tp&                        reference;
-      typedef ptrdiff_t                         difference_type;
-      typedef std::forward_iterator_tag         iterator_category;
+      typedef _Tp                                     value_type;
+      typedef typename _Alloc::const_pointer          pointer;
+      typedef typename _Alloc::const_reference        reference;
+      typedef typename _Alloc::difference_type        difference_type;
+      typedef std::forward_iterator_tag               iterator_category;
 
       _Fwd_list_const_iterator() : _M_node() { }
 
       explicit
-      _Fwd_list_const_iterator(const _Fwd_list_node_base* __n)
+      _Fwd_list_const_iterator(typename _Node_base::_Const_pointer __n) 
       : _M_node(__n) { }
 
       _Fwd_list_const_iterator(const iterator& __iter)
@@ -213,11 +230,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
 
       reference
       operator*() const
-      { return static_cast<_Node*>(this->_M_node)->_M_value; }
+      { return __static_pointer_cast<_Node*>(this->_M_node)->_M_value; }
 
       pointer
       operator->() const
-      { return &static_cast<_Node*>(this->_M_node)->_M_value; }
+      { return &__static_pointer_cast<_Node*>(this->_M_node)->_M_value; }
 
       _Self&
       operator++()
@@ -251,60 +268,61 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
           return _Fwd_list_const_iterator(0);
       }
 
-      const _Fwd_list_node_base* _M_node;
+      typename _Node_base::_Const_pointer _M_node;
     };
 
   /**
    *  @brief  Forward list iterator equality comparison.
    */
-  template<typename _Tp>
+  template<typename _Tp,class _Alloc>
     inline bool
-    operator==(const _Fwd_list_iterator<_Tp>& __x,
-               const _Fwd_list_const_iterator<_Tp>& __y)
+    operator==(const _Fwd_list_iterator<_Tp, _Alloc>& __x,
+               const _Fwd_list_const_iterator<_Tp, _Alloc>& __y)
     { return __x._M_node == __y._M_node; }
 
   /**
    *  @brief  Forward list iterator inequality comparison.
    */
-  template<typename _Tp>
+  template<typename _Tp,class _Alloc>
     inline bool
-    operator!=(const _Fwd_list_iterator<_Tp>& __x,
-               const _Fwd_list_const_iterator<_Tp>& __y)
+    operator!=(const _Fwd_list_iterator<_Tp, _Alloc>& __x,
+               const _Fwd_list_const_iterator<_Tp, _Alloc>& __y)
     { return __x._M_node != __y._M_node; }
 
   /**
    *  @brief  Base class for @forward_list.
    */
-  template<typename _Tp, typename _Alloc>
+  template<typename _Tp, typename _Alloc = allocator<_Tp> >
     struct _Fwd_list_base
     {
     protected:
-      typedef typename _Alloc::template rebind<_Fwd_list_node<_Tp>>::other
-        _Node_alloc_type;
-
       typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type;
 
+      typedef typename _Alloc::template 
+        rebind<_Fwd_list_node<_Tp, _Tp_alloc_type>>::other _Node_alloc_type;
+
       struct _Fwd_list_impl 
       : public _Node_alloc_type
       {
-       _Fwd_list_node_base _M_head;
+        _Fwd_list_node_base<_Tp_alloc_type> _M_head;
 
-       _Fwd_list_impl()
-       : _Node_alloc_type(), _M_head()
-       { }
+        _Fwd_list_impl()
+        : _Node_alloc_type(), _M_head()
+        { }
 
         _Fwd_list_impl(const _Node_alloc_type& __a)
-       : _Node_alloc_type(__a), _M_head()
-       { }
+        : _Node_alloc_type(__a), _M_head()
+        { }
       };
 
       _Fwd_list_impl _M_impl;
 
     public:
-      typedef _Fwd_list_iterator<_Tp        iterator;
-      typedef _Fwd_list_const_iterator<_Tp  const_iterator;
+      typedef _Fwd_list_iterator<_Tp, _Tp_alloc_type>        iterator;
+      typedef _Fwd_list_const_iterator<_Tp, _Tp_alloc_type>  const_iterator;
 
-      typedef _Fwd_list_node<_Tp>             _Node;
+      typedef _Fwd_list_node<_Tp, _Tp_alloc_type>            _Node;
+      typedef _Fwd_list_node_base<_Tp_alloc_type>            _Node_base;
 
       _Node_alloc_type&
       _M_get_Node_allocator()
@@ -326,56 +344,56 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
 
       _Fwd_list_base(_Fwd_list_base&& __lst, const _Alloc& __a)
       : _M_impl(__a)
-      { _Fwd_list_node_base::swap(this->_M_impl._M_head,
-                                  __lst._M_impl._M_head); }
+      { _Node_base::swap(this->_M_impl._M_head, 
+                         __lst._M_impl._M_head); }
 
       _Fwd_list_base(_Fwd_list_base&& __lst)
       : _M_impl(__lst._M_get_Node_allocator())
-      { _Fwd_list_node_base::swap(this->_M_impl._M_head,
-                                  __lst._M_impl._M_head); }
+      { _Node_base::swap(this->_M_impl._M_head, 
+                         __lst._M_impl._M_head); }
 
       ~_Fwd_list_base()
       { _M_erase_after(&_M_impl._M_head, 0); }
 
     protected:
 
-      _Node*
+      typename _Node::_Pointer
       _M_get_node()
       { return _M_get_Node_allocator().allocate(1); }
 
       template<typename... _Args>
-        _Node*
+        typename _Node::_Pointer
         _M_create_node(_Args&&... __args)
-       {
-         _Node* __node = this->_M_get_node();
-         try
-           {
-             _M_get_Node_allocator().construct(__node,
-                                             std::forward<_Args>(__args)...);
-             __node->_M_next = 0;
-           }
-         catch(...)
-           {
-             this->_M_put_node(__node);
-             __throw_exception_again;
-           }
-         return __node;
-       }
+        {
+          typename _Node::_Pointer __node = this->_M_get_node();
+          try
+            {
+              _M_get_Node_allocator().construct(__node,
+                                              std::forward<_Args>(__args)...);
+              __node->_M_next = 0;
+            }
+          catch(...)
+            {
+              this->_M_put_node(__node);
+              __throw_exception_again;
+            }
+          return __node;
+        }
 
       template<typename... _Args>
-        _Fwd_list_node_base*
+        typename _Node_base::_Pointer
         _M_insert_after(const_iterator __pos, _Args&&... __args);
 
       void
-      _M_put_node(_Node* __p)
+      _M_put_node(typename _Node::_Pointer __p)
       { _M_get_Node_allocator().deallocate(__p, 1); }
 
-      _Fwd_list_node_base*
-      _M_erase_after(_Fwd_list_node_base* __pos);
+      typename _Node_base::_Pointer
+      _M_erase_after(typename _Node_base::_Pointer __pos);
 
-      _Fwd_list_node_base*
-      _M_erase_after(_Fwd_list_node_base* __pos,
-                     _Fwd_list_node_base* __last);
+      typename _Node_base::_Pointer
+      _M_erase_after(typename _Node_base::_Pointer __pos, 
+                     typename _Node_base::_Pointer __last);
     };
 
   /**
@@ -415,7 +433,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     {
     private:
       typedef _Fwd_list_base<_Tp, _Alloc>                  _Base;
-      typedef _Fwd_list_node<_Tp>                          _Node;
+      typedef typename _Base::_Node                        _Node;
+      typedef typename _Base::_Node_base                   _Node_base;
       typedef typename _Base::_Tp_alloc_type               _Tp_alloc_type;
 
     public:
@@ -425,8 +444,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       typedef typename _Tp_alloc_type::const_pointer       const_pointer;
       typedef typename _Tp_alloc_type::reference           reference;
       typedef typename _Tp_alloc_type::const_reference     const_reference;
-      typedef _Fwd_list_iterator<_Tp>                      iterator;
-      typedef _Fwd_list_const_iterator<_Tp>                const_iterator;
+      typedef typename _Base::iterator                     iterator;
+      typedef typename _Base::const_iterator               const_iterator;
       typedef std::size_t                                  size_type;
       typedef std::ptrdiff_t                               difference_type;
       typedef _Alloc                                       allocator_type;
@@ -758,7 +778,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       reference
       front()
       {
-        _Node* __front = static_cast<_Node*>(this->_M_impl._M_head._M_next);
+        _Node* __front = __static_pointer_cast<_Node*>(this->_M_impl._M_head._M_next);
         return __front->_M_value;
       }
 
@@ -769,7 +789,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       const_reference
       front() const
       {
-        _Node* __front = static_cast<_Node*>(this->_M_impl._M_head._M_next);
+        _Node* __front =
+         __static_pointer_cast<_Node*>(this->_M_impl._M_head._M_next);
         return __front->_M_value;
       }
 
@@ -790,7 +811,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
         void
         emplace_front(_Args&&... __args)
         { this->_M_insert_after(cbefore_begin(),
-                               std::forward<_Args>(__args)...); }
+                                std::forward<_Args>(__args)...); }
 
       /**
        *  @brief  Add data to the front of the %forward_list.
@@ -846,7 +867,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
         iterator
         emplace_after(const_iterator __pos, _Args&&... __args)
         { return iterator(this->_M_insert_after(__pos,
-                                         std::forward<_Args>(__args)...)); }
+                                          std::forward<_Args>(__args)...)); }
 
       /**
        *  @brief  Inserts given value into %forward_list after specified
@@ -952,8 +973,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       iterator
       erase_after(const_iterator __pos)
       {
-        _Fwd_list_node_base* __tmp
-          = const_cast<_Fwd_list_node_base*>(__pos._M_node);
+        _Node_base* __tmp = __const_pointer_cast<_Node_base*>(__pos._M_node);
         if (__tmp)
           return iterator(this->_M_erase_after(__tmp));
         else
@@ -982,9 +1002,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       iterator
       erase_after(const_iterator __pos, iterator __last)
       {
-        _Fwd_list_node_base* __tmp
-          = const_cast<_Fwd_list_node_base*>(__pos._M_node);
-        return iterator(this->_M_erase_after(__tmp, __last._M_node));
+        _Node_base* __tmp = __const_pointer_cast<_Node_base*>(__pos._M_node);
+        return iterator(this->_M_erase_after(__tmp, &*__last._M_node));
       }
 
       /**
@@ -999,8 +1018,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
        */
       void
       swap(forward_list&& __list)
-      { _Fwd_list_node_base::swap(this->_M_impl._M_head,
-                                  __list._M_impl._M_head); }
+      { _Node_base::swap(this->_M_impl._M_head, __list._M_impl._M_head); }
 
       /**
        *  @brief Resizes the %forward_list to the specified number of
@@ -1188,7 +1206,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       void
       sort()
       {
-        _Node* __tmp = static_cast<_Node*>(&this->_M_impl._M_head);
+        _Node* __tmp = __static_pointer_cast<_Node*>(&this->_M_impl._M_head);
         __tmp->_M_sort_after(std::less<_Tp>());
       }
 
@@ -1201,10 +1219,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       template<typename _Comp>
         void
         sort(_Comp __comp)
-       {
-         _Node* __tmp = static_cast<_Node*>(&this->_M_impl._M_head);
-         __tmp->_M_sort_after(__comp);
-       }
+        {
+          _Node* __tmp = __static_pointer_cast<_Node*>(&this->_M_impl._M_head);
+          __tmp->_M_sort_after(__comp);
+        }
 
       /**
        *  @brief  Reverse the elements in list.
@@ -1216,15 +1234,15 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
 
     private:
       template<typename _Integer>
-       void
-       _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
-       { _M_fill_initialize(static_cast<size_type>(__n), __x); }
+        void
+        _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
+        { _M_fill_initialize(static_cast<size_type>(__n), __x); }
 
       // Called by the range constructor to implement [23.1.1]/9
       template<typename _InputIterator>
-       void
-       _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
-                              __false_type);
+        void
+        _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
+                               __false_type);
 
       // Called by forward_list(n,v,a), and the range constructor when it
       // turns out to be the same thing.
@@ -1263,7 +1281,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     operator<(const forward_list<_Tp, _Alloc>& __lx,
               const forward_list<_Tp, _Alloc>& __ly)
     { return std::lexicographical_compare(__lx.cbegin(), __lx.cend(),
-                                         __ly.cbegin(), __ly.cend()); }
+                                         __ly.cbegin(), __ly.cend()); }
 
   /// Based on operator==
   template<typename _Tp, typename _Alloc>
index 02b1a0d..bfc814d 100644 (file)
@@ -41,104 +41,104 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
   *          This node is assumed to be an empty head node (of type
   *          _Fwd_list_node_base).
   */
-  template<typename _Tp>
+  template<typename _Tp, class _Alloc>
     template<typename _Comp>
       void
-      _Fwd_list_node<_Tp>::
+      _Fwd_list_node<_Tp, _Alloc>::
       _M_sort_after(_Comp __comp)
       {
-       // If `next' is 0, return immediately.
-       _Fwd_list_node* __list = static_cast<_Fwd_list_node*>(this->_M_next);
-       if (!__list)
-         return;
-
-       unsigned long __insize = 1;
-
-       while (1)
-         {
-           _Fwd_list_node* __p = __list;
-           __list = 0;
-           _Fwd_list_node* __tail = 0;
-
-           // Count number of merges we do in this pass.
-           unsigned long __nmerges = 0;
-
-           while (__p)
-             {
-               ++__nmerges;
-               // There exists a merge to be done.
-               // Step `insize' places along from p.
-               _Fwd_list_node* __q = __p;
-               unsigned long __psize = 0;
-               for (unsigned long __i = 0; __i < __insize; ++__i)
-                 {
-                   ++__psize;
-                   __q = static_cast<_Fwd_list_node*>(__q->_M_next);
-                   if (!__q)
-                     break;
-                 }
-
-               // If q hasn't fallen off end, we have two lists to merge.
-               unsigned long __qsize = __insize;
-
-               // Now we have two lists; merge them.
-               while (__psize > 0 || (__qsize > 0 && __q))
-                 {
-                   // Decide whether next node of merge comes from p or q.
-                   _Fwd_list_node<_Tp>* __e;
-                   if (__psize == 0)
-                     {
-                       // p is empty; e must come from q.
-                       __e = __q;
-                       __q = static_cast<_Fwd_list_node*>(__q->_M_next);
-                       --__qsize;
-                     }
-                   else if (__qsize == 0 || !__q)
-                     {
-                       // q is empty; e must come from p.
-                       __e = __p;
-                       __p = static_cast<_Fwd_list_node*>(__p->_M_next);
-                       --__psize;
-                     }
-                   else if (__comp(__p->_M_value, __q->_M_value))
-                     {
-                       // First node of p is lower; e must come from p.
-                       __e = __p;
-                       __p = static_cast<_Fwd_list_node*>(__p->_M_next);
-                       --__psize;
-                     }
-                   else
-                     {
-                       // First node of q is lower; e must come from q.
-                       __e = __q;
-                       __q = static_cast<_Fwd_list_node*>(__q->_M_next);
-                       --__qsize;
-                     }
-
-                   // Add the next node to the merged list.
-                   if (__tail)
-                     __tail->_M_next = __e;
-                   else
-                     __list = __e;
-                   __tail = __e;
-                 }
-
-               // Now p has stepped `insize' places along, and q has too.
-               __p = __q;
-             }
-           __tail->_M_next = 0;
-
-           // If we have done only one merge, we're finished.
-           // Allow for nmerges == 0, the empty list case.
-           if (__nmerges <= 1)
-             {
-               this->_M_next = __list;
-               return;
-             }
-
-           // Otherwise repeat, merging lists twice the size.
-           __insize *= 2;
-         }
+        // If `next' is 0, return immediately.
+        _Pointer __list = __static_pointer_cast<_Pointer>(this->_M_next);
+        if (!__list)
+          return;
+
+        unsigned long __insize = 1;
+
+        while (1)
+          {
+            _Pointer __p = __list;
+            __list = 0;
+            _Pointer __tail = 0;
+
+            // Count number of merges we do in this pass.
+            unsigned long __nmerges = 0;
+
+            while (__p)
+              {
+                ++__nmerges;
+                // There exists a merge to be done.
+                // Step `insize' places along from p.
+                _Pointer __q = __p;
+                unsigned long __psize = 0;
+                for (unsigned long __i = 0; __i < __insize; ++__i)
+                  {
+                    ++__psize;
+                    __q = __static_pointer_cast<_Pointer>(__q->_M_next);
+                    if (!__q)
+                      break;
+                  }
+
+                // If q hasn't fallen off end, we have two lists to merge.
+                unsigned long __qsize = __insize;
+
+                // Now we have two lists; merge them.
+                while (__psize > 0 || (__qsize > 0 && __q))
+                  {
+                    // Decide whether next node of merge comes from p or q.
+                    _Pointer __e;
+                    if (__psize == 0)
+                      {
+                        // p is empty; e must come from q.
+                        __e = __q;
+                        __q = __static_pointer_cast<_Pointer>(__q->_M_next);
+                        --__qsize;
+                      }
+                    else if (__qsize == 0 || !__q)
+                      {
+                        // q is empty; e must come from p.
+                        __e = __p;
+                        __p = __static_pointer_cast<_Pointer>(__p->_M_next);
+                        --__psize;
+                      }
+                    else if (__comp(__p->_M_value, __q->_M_value))
+                      {
+                        // First node of p is lower; e must come from p.
+                        __e = __p;
+                        __p = __static_pointer_cast<_Pointer>(__p->_M_next);
+                        --__psize;
+                      }
+                    else
+                      {
+                        // First node of q is lower; e must come from q.
+                        __e = __q;
+                        __q = __static_pointer_cast<_Pointer>(__q->_M_next);
+                        --__qsize;
+                      }
+
+                    // Add the next node to the merged list.
+                    if (__tail)
+                      __tail->_M_next = __e;
+                    else
+                      __list = __e;
+                    __tail = __e;
+                  }
+
+                // Now p has stepped `insize' places along, and q has too.
+                __p = __q;
+              }
+            __tail->_M_next = 0;
+
+            // If we have done only one merge, we're finished.
+            // Allow for nmerges == 0, the empty list case.
+            if (__nmerges <= 1)
+              {
+                this->_M_next = __list;
+                return;
+              }
+
+            // Otherwise repeat, merging lists twice the size.
+            __insize *= 2;
+          }
       }
  
   template<typename _Tp, typename _Alloc>
@@ -147,62 +147,73 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     : _M_impl(__a)
     {
       this->_M_impl._M_head._M_next = 0;
-      _Fwd_list_node_base* __to = &this->_M_impl._M_head;
-      _Node* __curr = static_cast<_Node*>(__lst._M_impl._M_head._M_next);
+      typename _Node_base::_Pointer __to = &this->_M_impl._M_head;
+      typename _Node::_Pointer __curr 
+        = __static_pointer_cast<typename _Node::_Pointer>
+                               (__lst._M_impl._M_head._M_next);
       while (__curr)
-       {
-         __to->_M_next = _M_create_node(__curr->_M_value);
-         __to = __to->_M_next;
-         __curr = static_cast<_Node*>(__curr->_M_next);
-       }
+        {
+          __to->_M_next = _M_create_node(__curr->_M_value);
+          __to = __to->_M_next;
+          __curr = __static_pointer_cast<typename _Node::_Pointer>
+                                        (__curr->_M_next);
+        }
     }
 
   template<typename _Tp, typename _Alloc>
     template<typename... _Args>
-      _Fwd_list_node_base*
+      typename _Fwd_list_base<_Tp, _Alloc>::_Node_base::_Pointer
       _Fwd_list_base<_Tp, _Alloc>::
       _M_insert_after(const_iterator __pos, _Args&&... __args)
       {
-       _Fwd_list_node_base* __to
-         = const_cast<_Fwd_list_node_base*>(__pos._M_node);
-       _Node* __thing = _M_create_node(std::forward<_Args>(__args)...);
-       __thing->_M_next = __to->_M_next;
-       __to->_M_next = __thing;
-       return __to->_M_next;
+        typename _Node_base::_Pointer __to 
+          = __const_pointer_cast<typename _Node_base::_Pointer>
+                                (__pos._M_node);
+        typename _Node::_Pointer __thing 
+          = __static_pointer_cast<typename _Node::_Pointer>( 
+                _M_create_node(std::forward<_Args>(__args)...) );
+        __thing->_M_next = __to->_M_next;
+        __to->_M_next = __thing;
+        return __static_pointer_cast<typename _Node_base::_Pointer>
+                                    (__to->_M_next);
       }
 
   template<typename _Tp, typename _Alloc>
-    _Fwd_list_node_base*
+    typename _Fwd_list_base<_Tp, _Alloc>::_Node_base::_Pointer
     _Fwd_list_base<_Tp, _Alloc>::
-    _M_erase_after(_Fwd_list_node_base* __pos)
+    _M_erase_after(typename _Node_base::_Pointer __pos)
     {
-      _Node* __curr = static_cast<_Node*>(__pos->_M_next);
+      typename _Node::_Pointer __curr 
+        = __static_pointer_cast<typename _Node::_Pointer>(__pos->_M_next);
       if (__curr)
-       {
-         _Fwd_list_node_base* __next = __curr->_M_next;
-         __pos->_M_next = __next;
-         _M_get_Node_allocator().destroy(__curr);
-         _M_put_node(__curr);
-       }
+        {
+          typename _Node_base::_Pointer __next = __curr->_M_next;
+          __pos->_M_next = __next;
+          _M_get_Node_allocator().destroy(__curr);
+          _M_put_node(__curr);
+        }
       return __pos;
     }
 
   template<typename _Tp, typename _Alloc>
-    _Fwd_list_node_base*
+    typename _Fwd_list_base<_Tp, _Alloc>::_Node_base::_Pointer
     _Fwd_list_base<_Tp, _Alloc>::
-    _M_erase_after(_Fwd_list_node_base* __pos, _Fwd_list_node_base* __last)
+    _M_erase_after(typename _Node_base::_Pointer __pos, 
+                   typename _Node_base::_Pointer __last)
     {
-      _Node* __curr = static_cast<_Node*>(__pos->_M_next);
+      typename _Node::_Pointer __curr 
+        = __static_pointer_cast<typename _Node::_Pointer>(__pos->_M_next);
       while (__curr)
-       {
-         _Node* __temp = __curr;
-         __curr = static_cast<_Node*>(__curr->_M_next);
-         _M_get_Node_allocator().destroy(__temp);
-         _M_put_node(__temp);
-         __pos->_M_next = __curr;
-         if (__temp == __last)
-           break;
-       }
+        {
+          typename _Node::_Pointer __temp = __curr;
+          __curr = __static_pointer_cast<typename _Node::_Pointer>
+                                        (__curr->_M_next);
+          _M_get_Node_allocator().destroy(__temp);
+          _M_put_node(__temp);
+          __pos->_M_next = __curr;
+          if (__temp == __last)
+            break;
+        }
       return __pos;
     }
   
@@ -214,7 +225,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
                              __false_type)
       {
-        _Fwd_list_node_base* __to = &this->_M_impl._M_head;
+        typename _Node_base::_Pointer __to = &this->_M_impl._M_head;
         for (; __first != __last; ++__first)
           {
             __to->_M_next = this->_M_create_node(*__first);
@@ -229,7 +240,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     forward_list<_Tp, _Alloc>::
     _M_fill_initialize(size_type __n, const value_type& __value)
     {
-      _Fwd_list_node_base* __to = &this->_M_impl._M_head;
+      typename _Node_base::_Pointer __to = &this->_M_impl._M_head;
       for (; __n > 0; --__n)
         {
           __to->_M_next = this->_M_create_node(__value);
@@ -243,24 +254,24 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     operator=(const forward_list& __list)
     {
       if (&__list != this)
-       {
-         iterator __prev1 = before_begin();
-         iterator __curr1 = begin();
-         iterator __last1 = end();
-         const_iterator __first2 = __list.cbegin();
-         const_iterator __last2 = __list.cend();
-         while (__curr1 != __last1 && __first2 != __last2)
-           {
-             *__curr1 = *__first2;
-             ++__prev1;
-             ++__curr1;
-             ++__first2;
-           }
-         if (__first2 == __last2)
-           erase_after(__prev1, __last1);
-         else
-           insert_after(__prev1, __first2, __last2);
-       }
+        {
+          iterator __prev1 = before_begin();
+          iterator __curr1 = begin();
+          iterator __last1 = end();
+          const_iterator __first2 = __list.cbegin();
+          const_iterator __last2 = __list.cend();
+          while (__curr1 != __last1 && __first2 != __last2)
+            {
+              *__curr1 = *__first2;
+              ++__prev1;
+              ++__curr1;
+              ++__first2;
+            }
+          if (__first2 == __last2)
+            erase_after(__prev1, __last1);
+          else
+            insert_after(__prev1, __first2, __last2);
+        }
       return *this;
     }
 
@@ -273,14 +284,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
 
       size_type __len = 0;
       while (__k._M_next() != end() && __len < __sz)
-       {
-         ++__k;
-         ++__len;
-       }
+        {
+          ++__k;
+          ++__len;
+        }
       if (__len == __sz)
-       erase_after(__k, end());
+        erase_after(__k, end());
       else
-       insert_after(__k, __sz - __len, __val);
+        insert_after(__k, __sz - __len, __val);
     }
 
   template<typename _Tp, typename _Alloc>
@@ -289,27 +300,31 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     splice_after(const_iterator __pos, forward_list&& __list)
     {
       if (!__list.empty() && &__list != this)
-       {
-         _Fwd_list_node_base* __tmp
-           = const_cast<_Fwd_list_node_base*>(__pos._M_node);
-         const_iterator __before = __list.cbefore_begin();
-         __tmp->_M_transfer_after(const_cast<_Fwd_list_node_base*>
-                                  (__before._M_node));
-       }
+        {
+          typename _Node_base::_Pointer __tmp 
+            = __const_pointer_cast<typename _Node_base::_Pointer>
+                                  (__pos._M_node);
+          const_iterator __before = __list.cbefore_begin();
+          __tmp->_M_transfer_after(__const_pointer_cast
+                                     <typename _Node_base::_Pointer>
+                                     (__before._M_node));
+        }
     }
 
   template<typename _Tp, typename _Alloc>
     void
     forward_list<_Tp, _Alloc>::
     splice_after(const_iterator __pos, forward_list&& __list,
-                const_iterator __before, const_iterator __last)
+                 const_iterator __before, const_iterator __last)
     {
-      _Fwd_list_node_base* __tmp
-       = const_cast<_Fwd_list_node_base*>(__pos._M_node);
-      __tmp->_M_transfer_after(const_cast<_Fwd_list_node_base*>
-                              (__before._M_node),
-                              const_cast<_Fwd_list_node_base*>
-                              (__last._M_node));
+      typename _Node_base::_Pointer __tmp 
+        = __const_pointer_cast<typename _Node_base::_Pointer>(__pos._M_node);
+      __tmp->_M_transfer_after(__const_pointer_cast
+                                 <typename _Node_base::_Pointer>
+                                 (__before._M_node),
+                               __const_pointer_cast
+                                 <typename _Node_base::_Pointer>
+                                 (__last._M_node));
     }
 
   template<typename _Tp, typename _Alloc>
@@ -317,14 +332,18 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
     forward_list<_Tp, _Alloc>::
     remove(const _Tp& __val)
     {
-      _Node* __curr = static_cast<_Node*>(&this->_M_impl._M_head);
-      while (_Node* __temp = static_cast<_Node*>(__curr->_M_next))
-       {
-         if (__temp->_M_value == __val)
-           this->_M_erase_after(__curr);
-         else
-           __curr = static_cast<_Node*>(__curr->_M_next);
-       }
+      typename _Node::_Pointer __curr 
+        = __static_pointer_cast<typename _Node::_Pointer>
+                               (&this->_M_impl._M_head);
+      while (typename _Node::_Pointer __temp = 
+             __static_pointer_cast<typename _Node::_Pointer>(__curr->_M_next))
+        {
+          if (__temp->_M_value == __val)
+            this->_M_erase_after(__curr);
+          else
+            __curr = __static_pointer_cast<typename _Node::_Pointer>
+                                          (__curr->_M_next);
+        }
     }
 
   template<typename _Tp, typename _Alloc>
@@ -333,14 +352,18 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       forward_list<_Tp, _Alloc>::
       remove_if(_Pred __pred)
       {
-       _Node* __curr = static_cast<_Node*>(&this->_M_impl._M_head);
-       while (_Node* __temp = static_cast<_Node*>(__curr->_M_next))
-         {
-           if (__pred(__temp->_M_value))
-             this->_M_erase_after(__curr);
-           else
-             __curr = static_cast<_Node*>(__curr->_M_next);
-         }
+        typename _Node::_Pointer __curr 
+          = __static_pointer_cast<typename _Node::_Pointer>
+                                 (&this->_M_impl._M_head);
+        while (typename _Node::_Pointer __temp = 
+               __static_pointer_cast<typename _Node::_Pointer>(__curr->_M_next))
+          {
+            if (__pred(__temp->_M_value))
+              this->_M_erase_after(__curr);
+            else
+              __curr = __static_pointer_cast<typename _Node::_Pointer>
+                                            (__curr->_M_next);
+          }
       }
 
   template<typename _Tp, typename _Alloc>
@@ -352,16 +375,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
         iterator __first = begin();
         iterator __last = end();
         if (__first == __last)
-         return;
+          return;
         iterator __next = __first;
         while (++__next != __last)
-       {
-         if (__binary_pred(*__first, *__next))
-           erase_after(__first);
-         else
-           __first = __next;
-         __next = __first;
-       }
+        {
+          if (__binary_pred(*__first, *__next))
+            erase_after(__first);
+          else
+            __first = __next;
+          __next = __first;
+        }
       }
 
   template<typename _Tp, typename _Alloc>
@@ -370,13 +393,13 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
       forward_list<_Tp, _Alloc>::
       merge(forward_list&& __list, _Comp __comp)
       {
-        _Fwd_list_node_base* __node = &this->_M_impl._M_head;
+        typename _Node_base::_Pointer __node = &this->_M_impl._M_head;
         while (__node->_M_next && __list._M_impl._M_head._M_next)
           {
-            if (__comp(static_cast<_Node*>
-                      (__list._M_impl._M_head._M_next)->_M_value,
-                       static_cast<_Node*>
-                      (__node->_M_next)->_M_value))
+            if (__comp(__static_pointer_cast<typename _Node::_Pointer>
+                       (__list._M_impl._M_head._M_next)->_M_value,
+                       __static_pointer_cast<typename _Node::_Pointer>
+                       (__node->_M_next)->_M_value))
               __node->_M_transfer_after(&__list._M_impl._M_head,
                                         __list._M_impl._M_head._M_next);
             __node = __node->_M_next;
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/1.cc b/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/1.cc
new file mode 100644 (file)
index 0000000..c4b90b7
--- /dev/null
@@ -0,0 +1,99 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008 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 Pred 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 23.2.3.n forward_list capacity [lib.forward_list.capacity]
+
+#include <forward_list>
+#include <ext/extptr_allocator.h>
+#include <testsuite_hooks.h>
+
+bool test __attribute__((unused)) = true;
+
+using __gnu_cxx::_ExtPtr_allocator;
+
+// This test verifies the following.
+//
+void
+test01()
+{
+  std::forward_list<double, _ExtPtr_allocator<double> > fld;
+
+  VERIFY(fld.empty() == true);
+  fld.push_front(1.0);
+  VERIFY(fld.empty() == false);
+  fld.resize(0);
+  VERIFY(fld.empty() == true);
+}
+
+void
+test02()
+{
+  std::forward_list<int, _ExtPtr_allocator<int> > a, b;
+  a.push_front(1);
+
+  b = std::move(a);
+  VERIFY(b.empty() == false);
+  VERIFY(*b.begin() == 1);
+  VERIFY(a.empty() == true);
+
+  std::forward_list<int, _ExtPtr_allocator<int> > c(std::move(b));
+  VERIFY(c.empty() == false);
+  (*c.begin() == 1 );
+  VERIFY( b.empty() == true );
+}
+
+// Test various constrcutors 
+void
+test03()
+{
+  const int ni = 10;
+  int i[ni] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+
+  _ExtPtr_allocator<int>  alloc;
+
+  std::forward_list<int, _ExtPtr_allocator<int> > flccin(i, i+ni);
+  std::forward_list<int, _ExtPtr_allocator<int> > flc(flccin);
+  std::forward_list<int, _ExtPtr_allocator<int> > flm(std::move(flccin));
+  std::forward_list<int, _ExtPtr_allocator<int> > flcc(flccin, alloc );
+  std::forward_list<int, _ExtPtr_allocator<int> > flmc(
+       std::forward_list<int, _ExtPtr_allocator<int> >(i, i+ni), alloc);
+  std::forward_list<double, _ExtPtr_allocator<double> > flil(
+        {1.0, 2.0, 3.0, 4.0, 5.0});
+}
+
+// Test constrcutors 
+//   Construction from given number of default item
+//   Construction from given number of given item
+void
+test04()
+{
+  std::forward_list<double, _ExtPtr_allocator<double> > flvd(10);
+  std::forward_list<float, _ExtPtr_allocator<float> > flv(10, 5.0F);
+}
+
+int
+main()
+{
+  test01();
+  test02();
+  test03();
+  test04();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/modifiers/1.cc b/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/modifiers/1.cc
new file mode 100644 (file)
index 0000000..0df4d44
--- /dev/null
@@ -0,0 +1,76 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008 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 Pred 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 23.2.3.n forward_list xxx [lib.forward_list.xxx]
+
+#include <forward_list>
+#include <ext/extptr_allocator.h>
+#include <testsuite_hooks.h>
+
+#include <array>
+
+bool test __attribute__((unused)) = true;
+
+using __gnu_cxx::_ExtPtr_allocator;
+
+class PathPoint
+{
+public:
+  PathPoint(char t, std::array<double, 3> & c)
+  : type(t), coord(c) { }
+  char getType() const { return type; }
+private:
+  char type;
+  std::array<double, 3> coord;
+};
+
+// This test verifies the following.
+//   emplace_front
+//   pop_front
+//   emplace_after
+void
+test01()
+{
+  std::forward_list<PathPoint, _ExtPtr_allocator<PathPoint> > path;
+  std::array<double, 3> coord1 = { { 0.0, 1.0, 2.0 } };
+  path.emplace_front('a', coord1);
+
+  std::forward_list<PathPoint, _ExtPtr_allocator<PathPoint> >::const_iterator pos = path.cbegin();
+
+  std::array<double, 3> coord2 = { { 3.0, 4.0, 5.0 } };
+  path.emplace_after(pos, 'b', coord2);
+
+  VERIFY(path.front().getType() == 'a');
+
+  path.pop_front();
+
+  VERIFY(path.front().getType() == 'b');
+
+  path.pop_front();
+
+  VERIFY(path.empty() == true);
+}
+
+int
+main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/modifiers/2.cc b/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/modifiers/2.cc
new file mode 100644 (file)
index 0000000..27264b3
--- /dev/null
@@ -0,0 +1,151 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008 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 Pred 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 23.2.3.n forward_list xxx [lib.forward_list.xxx]
+
+#include <forward_list>
+#include <ext/extptr_allocator.h>
+#include <testsuite_hooks.h>
+
+#include <string>
+
+bool test __attribute__((unused)) = true;
+
+using __gnu_cxx::_ExtPtr_allocator;
+
+// This test verifies the following:
+//   insert_after single item
+//   before_begin iterator
+void
+test01()
+{
+  std::forward_list<int, _ExtPtr_allocator<int> > fl(
+    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
+
+  fl.insert_after(fl.before_begin(), 42);
+  VERIFY(fl.front() == 42);
+}
+
+// This test verifies the following:
+void
+test02()
+{
+  std::forward_list<int, _ExtPtr_allocator<int> > fl(
+    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
+
+  std::forward_list<int, _ExtPtr_allocator<int> >::const_iterator 
+    pos = fl.cbegin();
+
+  ++pos;
+  VERIFY(*pos == 1);
+
+  // Note: Calling l.insert_after(pos, 5, 42); without the long five
+  // gets resolved to the iterator range version and fails to compile!
+  fl.insert_after(pos, 5, 42);
+  VERIFY(*pos == 1);
+
+  ++pos;
+  VERIFY(*pos == 42);
+  ++pos;
+  ++pos;
+  ++pos;
+  ++pos;
+  VERIFY(*pos == 42);
+}
+
+// This test verifies the following:
+void
+test03()
+{
+  std::forward_list<int, _ExtPtr_allocator<int> > fl(
+    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
+
+  std::forward_list<int, _ExtPtr_allocator<int> >::const_iterator 
+    pos = fl.cbegin();
+
+  ++pos;
+  VERIFY(*pos == 1);
+
+  int i[3] = {666, 777, 888};
+  fl.insert_after(pos, i, i+3);
+  VERIFY(*pos == 1);
+
+  ++pos;
+  ++pos;
+  ++pos;
+  VERIFY(*pos == 888);
+  ++pos;
+  VERIFY(*pos == 2);
+}
+
+// This test verifies the following:
+void
+test04()
+{
+  std::forward_list<int, _ExtPtr_allocator<int> > fl(
+    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
+
+  std::forward_list<int, _ExtPtr_allocator<int> >::const_iterator 
+    pos = fl.cbegin();
+
+  ++pos;
+  VERIFY(*pos == 1);
+
+  fl.insert_after(pos, {-1, -2, -3, -4, -5});
+  VERIFY(*pos == 1);
+
+  ++pos;
+  ++pos;
+  ++pos;
+  VERIFY(*pos == -3);
+}
+
+// This test verifies the following:
+void
+test05()
+{
+  std::forward_list<std::string, _ExtPtr_allocator<std::string> > fl(
+    {"AAA", "BBB", "CCC"});
+
+  std::forward_list<std::string, _ExtPtr_allocator<std::string> >::const_iterator 
+    pos = fl.cbegin();
+
+  ++pos;
+  VERIFY(*pos == "BBB");
+
+  std::string x( "XXX" );
+  fl.insert_after(pos, std::move(x));
+  VERIFY(*pos == "BBB");
+  ++pos;
+  VERIFY(*pos == "XXX");
+  ++pos;
+  VERIFY(*pos == "CCC");
+}
+
+int
+main()
+{
+  test01();
+  test02();
+  test03();
+  test04();
+  test05();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/modifiers/3.cc b/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/modifiers/3.cc
new file mode 100644 (file)
index 0000000..24ac788
--- /dev/null
@@ -0,0 +1,98 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008 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 Pred 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 23.2.3.n forward_list xxx [lib.forward_list.xxx]
+
+#include <forward_list>
+#include <ext/extptr_allocator.h>
+#include <testsuite_hooks.h>
+
+bool test __attribute__((unused)) = true;
+
+using __gnu_cxx::_ExtPtr_allocator;
+
+// This test verifies the following:
+//   cbegin
+//   erase_after one iterator
+//   pos is useable and points to current element
+void
+test01()
+{
+  std::forward_list<int, _ExtPtr_allocator<int> > fl(
+    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
+
+  std::forward_list<int, _ExtPtr_allocator<int> >::const_iterator 
+    pos = fl.cbegin();
+
+  ++pos;
+  VERIFY(*pos == 1);
+
+  std::forward_list<int, _ExtPtr_allocator<int> >::iterator 
+    next = fl.erase_after(pos);
+
+  VERIFY(*next == 1);
+
+  VERIFY(*pos == 1);
+  ++pos;
+  VERIFY(*pos == 3);
+}
+
+// This test verifies the following:
+//   cbegin
+//   erase_after iterator range
+//   pos is useable and points to current element
+void
+test02()
+{
+  std::forward_list<int, _ExtPtr_allocator<int> > fl(
+    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
+
+  std::forward_list<int, _ExtPtr_allocator<int> >::const_iterator 
+    pos = fl.cbegin();
+
+  ++pos;
+  VERIFY(*pos == 1);
+
+  std::forward_list<int, _ExtPtr_allocator<int> >::iterator 
+    stop = fl.begin();
+
+  ++stop;
+  ++stop;
+  ++stop;
+  ++stop;
+  VERIFY(*stop == 4);
+
+  std::forward_list<int, _ExtPtr_allocator<int> >::iterator 
+    next = fl.erase_after(pos, stop);
+
+  VERIFY(*next == 1);
+
+  VERIFY(*pos == 1);
+  ++pos;
+  VERIFY(*pos == 5);
+}
+
+int
+main()
+{
+  test01();
+  test02();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/modifiers/4.cc b/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/modifiers/4.cc
new file mode 100644 (file)
index 0000000..6e947fd
--- /dev/null
@@ -0,0 +1,49 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008 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 Pred 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 23.2.3.n forward_list xxx [lib.forward_list.xxx]
+
+#include <forward_list>
+#include <ext/extptr_allocator.h>
+#include <testsuite_hooks.h>
+
+bool test __attribute__((unused)) = true;
+
+
+// This test verifies the following:
+//   swap
+void
+test01()
+{
+  std::forward_list<int> fl1({0, 1, 2, 3, 4, 5});
+  std::forward_list<int> fl2({666, 777, 888});
+
+  fl1.swap(fl2);
+
+  VERIFY(fl1.front() == 666);
+  VERIFY(fl2.front() == 0);
+}
+
+int
+main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/modifiers/5.cc b/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/modifiers/5.cc
new file mode 100644 (file)
index 0000000..114b9bd
--- /dev/null
@@ -0,0 +1,49 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008 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 Pred 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 23.2.3.n forward_list xxx [lib.forward_list.xxx]
+
+#include <forward_list>
+#include <ext/extptr_allocator.h>
+#include <testsuite_hooks.h>
+
+bool test __attribute__((unused)) = true;
+
+// This test verifies the following:
+//   clear
+void
+test01()
+{
+  std::forward_list<int, __gnu_cxx::_ExtPtr_allocator<int> > fl(
+    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
+
+  VERIFY(fl.empty() == false);
+
+  fl.clear();
+
+  VERIFY(fl.empty() == true);
+}
+
+int
+main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/1.cc b/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/1.cc
new file mode 100644 (file)
index 0000000..dcb7592
--- /dev/null
@@ -0,0 +1,116 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008 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 Pred 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 23.2.3.n forward_list xxx [lib.forward_list.xxx]
+
+#include <forward_list>
+#include <testsuite_hooks.h>
+#include <ext/extptr_allocator.h>
+
+using __gnu_cxx::_ExtPtr_allocator;
+
+bool test __attribute__((unused)) = true;
+
+// This test verifies the following:
+//   
+void
+test01()
+{
+  typedef std::forward_list<double, _ExtPtr_allocator<double> > fwd_list_type;
+
+  fwd_list_type a = {0.0, 1.0, 2.0, 3.0, 4.0};
+  fwd_list_type::const_iterator posa = a.cbefore_begin();
+
+  fwd_list_type x = {666.0, 777.0, 888.0};
+
+  a.splice_after(posa, x);
+
+  ++posa;
+  VERIFY(*posa == 666.0);
+
+  VERIFY(x.empty() == true);
+}
+
+// This test verifies the following:
+//   
+void
+test02()
+{
+  typedef std::forward_list<double, _ExtPtr_allocator<double> > fwd_list_type;
+
+  fwd_list_type a = {0.0, 1.0, 2.0, 3.0, 4.0};
+  fwd_list_type::const_iterator posa = a.cbefore_begin();
+  ++posa;
+  VERIFY(*posa == 0.0);
+
+  fwd_list_type y = {10.0, 11.0, 12.0, 13.0, 14.0, 15.0};
+  fwd_list_type::const_iterator befy = y.cbefore_begin();
+  ++befy;
+  VERIFY(*befy == 10.0);
+  fwd_list_type::const_iterator endy = befy;
+  ++endy;
+  ++endy;
+  ++endy;
+  ++endy;
+  VERIFY(*endy == 14.0);
+
+  a.splice_after(posa, y, befy, endy);
+  VERIFY(*posa == 0.0);
+
+  VERIFY(*befy == 10.0);
+  ++befy;
+  VERIFY(*befy == 15.0);
+}
+
+// This test verifies the following:
+//   
+void
+test03()
+{
+  typedef std::forward_list<double, _ExtPtr_allocator<double> > fwd_list_type;
+
+  fwd_list_type a = {0.0, 1.0, 2.0, 3.0, 4.0};
+  fwd_list_type::const_iterator posa = a.cbefore_begin();
+  ++posa;
+  ++posa;
+  VERIFY(*posa == 1.0);
+
+  fwd_list_type z = {42.0, 43.0, 44.0};
+  fwd_list_type::const_iterator posz = z.begin();
+  VERIFY(*posz == 42.0);
+
+  a.splice_after(posa, z, posz);
+  VERIFY(*posa == 1.0);
+  ++posa;
+  VERIFY(*posa == 43.0);
+
+  VERIFY(*posz == 42.0);
+  ++posz;
+  VERIFY(*posz == 44.0);
+}
+
+int
+main()
+{
+  test01();
+  test02();
+  test03();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/2.cc b/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/2.cc
new file mode 100644 (file)
index 0000000..245bc41
--- /dev/null
@@ -0,0 +1,57 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008 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 Pred 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 23.2.3.n forward_list xxx [lib.forward_list.xxx]
+
+#include <forward_list>
+#include <testsuite_hooks.h>
+#include <ext/extptr_allocator.h>
+
+using __gnu_cxx::_ExtPtr_allocator;
+
+bool test __attribute__((unused)) = true;
+
+// This test verifies the following:
+//   remove
+void
+test01()
+{
+  std::forward_list<int, _ExtPtr_allocator<int> > fl =
+    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+
+  fl.remove(7);
+
+  std::forward_list<int, _ExtPtr_allocator<int> >::const_iterator 
+    pos = fl.cbefore_begin();
+
+  for (std::size_t i = 0; i < 7; ++i)
+    ++pos;
+  VERIFY(*pos == 6);
+
+  ++pos;
+  VERIFY(*pos == 8);
+}
+
+int
+main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/3.cc b/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/3.cc
new file mode 100644 (file)
index 0000000..4290f46
--- /dev/null
@@ -0,0 +1,53 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008 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 Pred 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 23.2.3.n forward_list xxx [lib.forward_list.xxx]
+
+#include <forward_list>
+#include <testsuite_hooks.h>
+#include <ext/extptr_allocator.h>
+
+#include <algorithm>
+
+bool test __attribute__((unused)) = true;
+
+using __gnu_cxx::_ExtPtr_allocator;
+
+// This test verifies the following:
+//   remove_if
+void
+test01()
+{
+  std::forward_list<int, _ExtPtr_allocator<int> > fl =
+    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+
+  fl.remove_if(std::bind2nd(std::less<int>(),5));
+
+  std::forward_list<int, _ExtPtr_allocator<int> >::const_iterator 
+    pos = fl.cbegin();
+  VERIFY(*pos == 5);
+}
+
+int
+main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/4.cc b/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/4.cc
new file mode 100644 (file)
index 0000000..62a8bf4
--- /dev/null
@@ -0,0 +1,86 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008 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 Pred 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 23.2.3.n forward_list xxx [lib.forward_list.xxx]
+
+#include <forward_list>
+#include <testsuite_hooks.h>
+#include <ext/extptr_allocator.h>
+
+using __gnu_cxx::_ExtPtr_allocator;
+
+bool test __attribute__((unused)) = true;
+
+// This test verifies the following:
+//   unique
+void
+test01()
+{
+  std::forward_list<int, _ExtPtr_allocator<int> > fl = 
+    {99, 5, 99, 6, -5, 666, 777, 888, 42, 42, 42, 42, 42, 7, 0, 0, 0, 9, 9, 9};
+
+  fl.unique();
+
+  std::forward_list<int, _ExtPtr_allocator<int> > fl2 = 
+    {99, 5, 99, 6, -5, 666, 777, 888, 42, 7, 0, 9};
+
+  VERIFY(fl == fl2);
+}
+
+//  Test comparison predicate.
+template<typename Num>
+  class Mod
+  {
+  public:
+    Mod(const Num & mod)
+      {
+        m = mod;
+      }
+    bool operator()(const Num i, const Num j)
+      {
+        return i%m == j%m;
+      }
+  private:
+    Num m;
+  };
+
+// This test verifies the following:
+//   unique with predicate
+void
+test02()
+{
+  std::forward_list<int, _ExtPtr_allocator<int> > fl = 
+    {99, 5, 99, 6, -5, 666, 777, 888, 42, 7, 0, 9};
+
+  fl.unique(Mod<int>(111));
+
+  std::forward_list<int, _ExtPtr_allocator<int> > fl2 = 
+    {99, 5, 99, 6, -5, 666, 42, 7, 0, 9};
+
+  VERIFY(fl == fl2);
+}
+
+int
+main()
+{
+  test01();
+  test02();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/5.cc b/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/5.cc
new file mode 100644 (file)
index 0000000..1f43f21
--- /dev/null
@@ -0,0 +1,53 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008 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 Pred 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 23.2.3.n forward_list xxx [lib.forward_list.xxx]
+
+#include <forward_list>
+#include <testsuite_hooks.h>
+#include <ext/extptr_allocator.h>
+
+using __gnu_cxx::_ExtPtr_allocator;
+
+bool test __attribute__((unused)) = true;
+
+// This test verifies the following:
+//   
+void
+test01()
+{
+  typedef std::forward_list<double, _ExtPtr_allocator<double> > fwd_list_type;
+
+  fwd_list_type a = {0.0, 1.0, 2.0, 3.0, 4.0};
+  fwd_list_type b = {1.0, 2.0, 3.0, 4.0, 4.0, 5.0};
+
+  a.merge(b);
+
+  fwd_list_type r = {0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 4.0, 5.0};
+
+  VERIFY(a == r);
+}
+
+int
+main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/6.cc b/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/6.cc
new file mode 100644 (file)
index 0000000..a358056
--- /dev/null
@@ -0,0 +1,89 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008 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 Pred 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 23.2.3.n forward_list xxx [lib.forward_list.xxx]
+
+#include <forward_list>
+#include <testsuite_hooks.h>
+#include <ext/extptr_allocator.h>
+
+using __gnu_cxx::_ExtPtr_allocator;
+
+bool test __attribute__((unused)) = true;
+
+//  Comparison functor.
+template<typename Num>
+  class Comp
+  {
+  public:
+    Comp(const Num & num)
+      {
+        n = num;
+      }
+    bool operator()(const Num i, const Num j)
+      {
+        return (n * i) < (n * j);
+      }
+  private:
+    Num n;
+  };
+
+// This test verifies the following:
+//   
+void
+test01()
+{
+  typedef std::forward_list<int, _ExtPtr_allocator<int> > fwd_list_type;
+
+  const unsigned int n = 13;
+  int order[][n] = {
+    { 0,1,2,3,4,5,6,7,8,9,10,11,12 },
+    { 6,2,8,4,11,1,12,7,3,9,5,0,10 },
+    { 12,11,10,9,8,7,6,5,4,3,2,1,0 },
+  };
+  fwd_list_type sorted(order[0], order[0] + n);
+
+  for (unsigned int i = 0; i < sizeof(order)/sizeof(*order); ++i)
+    {
+      fwd_list_type head(order[i], order[i] + n);
+
+      head.sort();
+
+      VERIFY(head == sorted);
+    }
+
+  fwd_list_type reversed(order[2], order[2] + n);
+  for (unsigned int i = 0; i < sizeof(order)/sizeof(*order); ++i)
+    {
+      fwd_list_type head(order[i], order[i] + n);
+
+      Comp<int> comp(-1);
+      head.sort( comp );
+
+      VERIFY(head == reversed);
+    }
+}
+
+int
+main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/7.cc b/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/operations/7.cc
new file mode 100644 (file)
index 0000000..e73504c
--- /dev/null
@@ -0,0 +1,58 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008 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 Pred 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 23.2.3.n forward_list xxx [lib.forward_list.xxx]
+
+#include <forward_list>
+#include <testsuite_hooks.h>
+#include <ext/extptr_allocator.h>
+
+#include <algorithm>
+
+using __gnu_cxx::_ExtPtr_allocator;
+
+bool test __attribute__((unused)) = true;
+
+// This test verifies the following:
+//   
+void
+test01()
+{
+  const unsigned int n = 13;
+  int order[n] = {0,1,2,3,4,5,6,7,8,9,10,11,12};
+
+  std::forward_list<int, _ExtPtr_allocator<int> > fl(order, order + n);
+
+  std::forward_list<int, _ExtPtr_allocator<int> > fl2;
+  for (std::size_t i = 0; i < n; ++i)
+    fl2.push_front(order[i]);
+
+  fl.reverse();
+
+  VERIFY(std::lexicographical_compare(fl.begin(), fl.end(),
+                                      fl2.begin(), fl2.end()) == false);
+}
+
+int
+main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/requirements/1.cc b/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/requirements/1.cc
new file mode 100644 (file)
index 0000000..484df00
--- /dev/null
@@ -0,0 +1,73 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008 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 Pred 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 23.2.3.n forward_list xxx [lib.forward_list.xxx]
+
+#include <forward_list>
+#include <ext/extptr_allocator.h>
+#include <testsuite_hooks.h>
+
+using __gnu_cxx::_ExtPtr_allocator;
+
+bool test __attribute__((unused)) = true;
+
+// A nontrivial type.
+template<typename T>
+  struct A { };
+
+// Another nontrivial type
+struct B { };
+
+// A nontrivial type convertible from an int
+struct C
+{
+  C(int i) : i_(i) { }
+  bool operator==(const C& rhs) { return i_ == rhs.i_; }
+  int i_;
+};
+
+// This test verifies the following.
+//
+void
+test01()
+{
+  std::forward_list< A<B>, _ExtPtr_allocator<A<B> > > lst;
+  VERIFY(lst.begin() == lst.end());
+  VERIFY(std::distance(lst.begin(), lst.end()) == 0);
+
+  // check type definitions -- will fail compile if missing
+  typedef std::forward_list< A<B> >::reference              reference;
+  typedef std::forward_list< A<B> >::const_reference        const_reference;
+  typedef std::forward_list< A<B> >::iterator               iterator;
+  typedef std::forward_list< A<B> >::const_iterator         const_iterator;
+  typedef std::forward_list< A<B> >::size_type              size_type;
+  typedef std::forward_list< A<B> >::difference_type        difference_type;
+  typedef std::forward_list< A<B> >::value_type             value_type;
+  typedef std::forward_list< A<B> >::allocator_type         allocator_type;
+  typedef std::forward_list< A<B> >::pointer                pointer;
+  typedef std::forward_list< A<B> >::const_pointer          const_pointer;
+}
+
+int
+main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/requirements/explicit_instantiation/1.cc
new file mode 100644 (file)
index 0000000..900508e
--- /dev/null
@@ -0,0 +1,36 @@
+// { dg-options "-std=gnu++0x" }
+// Copyright (C) 2008 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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.
+
+// This file tests explicit instantiation of library containers
+
+#include <forward_list>
+#include <ext/extptr_allocator.h>
+
+// { dg-do compile }
+
+template class std::forward_list<int, __gnu_cxx::_ExtPtr_allocator<int> >;
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/requirements/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/23_containers/forward_list/ext_pointer/requirements/explicit_instantiation/3.cc
new file mode 100644 (file)
index 0000000..6d8e5c5
--- /dev/null
@@ -0,0 +1,38 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2008 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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.
+
+// This file tests explicit instantiation of library containers
+
+#include <forward_list>
+#include <ext/extptr_allocator.h>
+
+// { dg-do compile }
+
+// libstdc++/21770
+template class std::forward_list<int, __gnu_cxx::_ExtPtr_allocator<char> >;