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]

Re: ping?


Paolo Carlini wrote:

Thanks for the ChangeLogs: actually, the second one should mention the new __iter_swap struct, I will fix that, then post the final patch...

Here it is, tested x86-linux, if nobody will object during the next 24 hours,
I will apply it.


Paolo.

//////////////
2004-10-05  Christopher Jefferson  <caj@cs.york.ac.uk>

	* include/bits/stl_algobase.h (iter_swap): delegate std::iter_swap
	to swap via __iter_swap when iterator's value_types are equal.
	(struct __iter_swap): New.

diff -prN libstdc++-v3-orig/include/bits/stl_algobase.h libstdc++-v3/include/bits/stl_algobase.h
*** libstdc++-v3-orig/include/bits/stl_algobase.h	Tue Sep 14 20:35:21 2004
--- libstdc++-v3/include/bits/stl_algobase.h	Mon Oct  4 18:21:47 2004
***************
*** 77,82 ****
--- 77,133 ----
  
  namespace std
  {
+ 
+   /**
+    *  @brief Swaps two values.
+    *  @param  a  A thing of arbitrary type.
+    *  @param  b  Another thing of arbitrary type.
+    *  @return   Nothing.
+    *
+    *  This is the simple classic generic implementation.  It will work on
+    *  any type which has a copy constructor and an assignment operator.
+   */
+   template<typename _Tp>
+     inline void
+     swap(_Tp& __a, _Tp& __b)
+     {
+       // concept requirements
+       __glibcxx_function_requires(_SGIAssignableConcept<_Tp>)
+ 
+       const _Tp __tmp = __a;
+       __a = __b;
+       __b = __tmp;
+     }
+ 
+   // See http://gcc.gnu.org/ml/libstdc++/2004-08/msg00167.html: in a
+   // nutshell, we are partially implementing the resolution of DR 187,
+   // when it's safe, i.e., the value_types are equal.
+   template<bool _BoolType>
+     struct __iter_swap
+     {
+       template<typename _ForwardIterator1, typename _ForwardIterator2>
+         static void
+         iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
+         {
+           typedef typename iterator_traits<_ForwardIterator1>::value_type
+             _ValueType1;
+           const _ValueType1 __tmp = *__a;
+           *__a = *__b;
+           *__b = __tmp; 
+ 	}
+     };
+ 
+   template<>
+     struct __iter_swap<true>
+     {
+       template<typename _ForwardIterator1, typename _ForwardIterator2>
+         static void 
+         iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
+         {
+           swap(*__a, *__b);
+         }
+     };
+ 
    /**
     *  @brief Swaps the contents of two iterators.
     *  @param  a  An iterator.
*************** namespace std
*** 104,134 ****
  				  _ValueType2>)
        __glibcxx_function_requires(_ConvertibleConcept<_ValueType2,
  				  _ValueType1>)
! 
!       const _ValueType1 __tmp = *__a;
!       *__a = *__b;
!       *__b = __tmp;
!     }
! 
!   /**
!    *  @brief Swaps two values.
!    *  @param  a  A thing of arbitrary type.
!    *  @param  b  Another thing of arbitrary type.
!    *  @return   Nothing.
!    *
!    *  This is the simple classic generic implementation.  It will work on
!    *  any type which has a copy constructor and an assignment operator.
!   */
!   template<typename _Tp>
!     inline void
!     swap(_Tp& __a, _Tp& __b)
!     {
!       // concept requirements
!       __glibcxx_function_requires(_SGIAssignableConcept<_Tp>)
! 
!       const _Tp __tmp = __a;
!       __a = __b;
!       __b = __tmp;
      }
  
    #undef min
--- 155,162 ----
  				  _ValueType2>)
        __glibcxx_function_requires(_ConvertibleConcept<_ValueType2,
  				  _ValueType1>)
!       std::__iter_swap<__are_same<_ValueType1, _ValueType2>::_M_type>::
! 	iter_swap(__a, __b);
      }
  
    #undef min

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