This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3] Small tweaks to forward_list


Hi,

tested x86_64-linux, committed to mainline.

Paolo.

///////////////////
2008-10-15  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/bits/forward_list.h (forward_list<>::max_size): Use
	Node_allocator; minor cosmetic changes.
	* testsuite/23_containers/forward_list/capacity/1.cc: Adjust.
Index: include/bits/forward_list.h
===================================================================
*** include/bits/forward_list.h	(revision 141146)
--- include/bits/forward_list.h	(working copy)
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 604,612 ****
         *  that the resulting %forward_list's size is the same as the number
         *  of elements assigned.  Old data may be lost.
         */
!       template<typename InputIterator>
          void
!         assign(InputIterator __first, InputIterator __last)
          {
            clear();
            insert_after(cbefore_begin(), __first, __last);
--- 604,612 ----
         *  that the resulting %forward_list's size is the same as the number
         *  of elements assigned.  Old data may be lost.
         */
!       template<typename _InputIterator>
          void
!         assign(_InputIterator __first, _InputIterator __last)
          {
            clear();
            insert_after(cbefore_begin(), __first, __last);
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 743,749 ****
         */
        size_type
        max_size() const
!       { return _Alloc().max_size(); }
  
        // 23.2.3.3 element access:
  
--- 743,749 ----
         */
        size_type
        max_size() const
!       { return this->_M_get_Node_allocator().max_size(); }
  
        // 23.2.3.3 element access:
  
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 783,791 ****
         *  and references.
         */
        template<typename... _Args>
!       void
!       emplace_front(_Args&&... __args)
!       { _M_insert_after(cbefore_begin(), std::forward<_Args>(__args)...); }
  
        /**
         *  @brief  Add data to the front of the %forward_list.
--- 783,791 ----
         *  and references.
         */
        template<typename... _Args>
!         void
!         emplace_front(_Args&&... __args)
!         { _M_insert_after(cbefore_begin(), std::forward<_Args>(__args)...); }
  
        /**
         *  @brief  Add data to the front of the %forward_list.
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 838,846 ****
         *  and references.
         */
        template<typename... _Args>
!       iterator
!       emplace_after(const_iterator __pos, _Args&&... __args)
!       { _M_insert_after(__pos, std::forward<_Args>(__args)...); }
  
        /**
         *  @brief  Inserts given value into %forward_list after specified
--- 838,846 ----
         *  and references.
         */
        template<typename... _Args>
!         iterator
!         emplace_after(const_iterator __pos, _Args&&... __args)
!         { _M_insert_after(__pos, std::forward<_Args>(__args)...); }
  
        /**
         *  @brief  Inserts given value into %forward_list after specified
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 893,900 ****
         *  does not invalidate iterators and references.
         */
        void
!       insert_after(const_iterator __pos,
!                    size_type __n, const _Tp& __val);
  
        /**
         *  @brief  Inserts a range into the %forward_list.
--- 893,900 ----
         *  does not invalidate iterators and references.
         */
        void
!       insert_after(const_iterator __pos, size_type __n,
! 		   const _Tp& __val);
  
        /**
         *  @brief  Inserts a range into the %forward_list.
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 1055,1062 ****
         *  Requires this != @a x.
         */
        void
!       splice_after(const_iterator __pos,
!                    forward_list&& __list)
        {
          if (!__list.empty() && &__list != this)
            {
--- 1055,1061 ----
         *  Requires this != @a x.
         */
        void
!       splice_after(const_iterator __pos, forward_list&& __list)
        {
          if (!__list.empty() && &__list != this)
            {
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 1079,1086 ****
         *  inserts it into the current list after @a pos.
         */
        void
!       splice_after(const_iterator __pos,
!                    forward_list&& __list,
                     const_iterator __it)
        { this->splice_after(__pos, __list, __it, __it._M_next()); }
  
--- 1078,1084 ----
         *  inserts it into the current list after @a pos.
         */
        void
!       splice_after(const_iterator __pos, forward_list&& __list,
                     const_iterator __it)
        { this->splice_after(__pos, __list, __it, __it._M_next()); }
  
*************** _GLIBCXX_BEGIN_NAMESPACE(std)
*** 1098,1107 ****
         *  Undefined if @a pos is in (before,last).
         */
        void
!       splice_after(const_iterator __pos,
!                    forward_list&& __list,
!                    const_iterator __before,
!                    const_iterator __last)
        {
          _Fwd_list_node_base* __tmp
            = const_cast<_Fwd_list_node_base* const>(__pos._M_node);
--- 1096,1103 ----
         *  Undefined if @a pos is in (before,last).
         */
        void
!       splice_after(const_iterator __pos, forward_list&& __list,
!                    const_iterator __before, const_iterator __last)
        {
          _Fwd_list_node_base* __tmp
            = const_cast<_Fwd_list_node_base* const>(__pos._M_node);
Index: testsuite/23_containers/forward_list/capacity/1.cc
===================================================================
*** testsuite/23_containers/forward_list/capacity/1.cc	(revision 141146)
--- testsuite/23_containers/forward_list/capacity/1.cc	(working copy)
*************** test01()
*** 39,45 ****
    fld.resize(0);
    VERIFY(fld.empty() == true);
  
!   VERIFY(fld.max_size() == fld.get_allocator().max_size());
  }
  
  int
--- 39,46 ----
    fld.resize(0);
    VERIFY(fld.empty() == true);
  
!   VERIFY( fld.max_size()
! 	  == std::allocator<std::_Fwd_list_node<double> >().max_size() );
  }
  
  int

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]