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]

[patch] : more delegation in stl_algo.h


For those interested, the reason why I couldn't use the existing bind2nd is that it assumes you inherit from binary_function or at least define various typedefs. We I think shouldn't start assuming now user code does this, and also such things aren't compatable with clever templated operator()s , like we already added!

Apart from that, this patch is hopefully mostly fairly obvious, with the exception that replace_copy of used to have a construct "z = p ? x : y" which I've replaced with "if(z) p=x else p=y", as in theory x and y can be of different types, neither convertable to the other but both convertable to typeof(z).

Previously mentioned optimisations to search and search_n will follow shortly once I can figure out why they don't seem to be working :)

Chris
2005-03-08  Christopher Jefferson  <chris@bubblescope.net>

	* include/bits/stl_algobase.h (min) : Readd lost comment.
	* include/bits/predefined_ops.h (bind2nd) : New internal
	predicate.
	(equal) : New.
	(equal_to::operator()) : Add const.
	(less::operator()) : Add const.
	* include/bits/stl_algo.h (find) : Delegate to find_if.
	(__find) : Remove unused overloads.
	(count) : Delegate to count_if.
	(replace) : Delegate to replace_if.
	(replace_copy) : Delegate to replace_copy_if.
	(remove_copy) : Delegate to remove_copy_if.
	(remove) : Delegate to remove_if.
	(replace_copy_if) : Replace ternary operator with if.
	* testsuite/testsuite_iterators.h (WritableObject::WritableObject) :
	Add const.
	* testsuite/25_algorithms/find/1.cc : New.
	* testsuite/25_algorithms/find/check_type.cc : New.
	* testsuite/25_algorithms/find_if/1.cc : New.
	* testsuite/25_algorithms/find_if/check_type.cc : New.
	* testsuite/25_algorithms/replace/1.cc : New.
	* testsuite/25_algorithms/replace/check_type.cc : New.
	* testsuite/25_algorithms/replace_if/1.cc : New.
	* testsuite/25_algorithms/replace_if/check_type.cc : New.
	* testsuite/25_algorithms/replace_copy/1.cc : New.
	* testsuite/25_algorithms/replace_copy/check_type.cc : New.
	* testsuite/25_algorithms/replace_copy_if/1.cc : New.
	* testsuite/25_algorithms/replace_copy_if/check_type.cc : New.
	* testsuite/25_algorithms/remove/1.cc : New.
	* testsuite/25_algorithms/remove/check_type.cc : New.
	* testsuite/25_algorithms/remove_if/1.cc : New.
	* testsuite/25_algorithms/remove_if/check_type.cc : New.
	* testsuite/25_algorithms/count/1.cc : New.
	* testsuite/25_algorithms/count/check_type.cc : New.
	* testsuite/25_algorithms/count_if/1.cc : New.
	* testsuite/25_algorithms/count_if/check_type.cc : New.
diff -rNu -x '*CVS*' libstdc++-v3.so_7.clean/include/bits/predefined_ops.h libstdc++-v3/include/bits/predefined_ops.h
--- libstdc++-v3.so_7.clean/include/bits/predefined_ops.h	2005-01-10 10:52:11.000000000 +0000
+++ libstdc++-v3/include/bits/predefined_ops.h	2005-03-09 00:57:13.574567856 +0000
@@ -43,7 +43,7 @@
   {
     template<typename _Lhs, typename _Rhs>
       bool
-      operator()(const _Lhs& __lhs, const _Rhs& __rhs)
+      operator()(const _Lhs& __lhs, const _Rhs& __rhs) const
       { return __lhs < __rhs; }
   };
 
@@ -51,9 +51,35 @@
   {
     template<typename _Lhs, typename _Rhs>
       bool
-      operator()(const _Lhs& __lhs, const _Rhs& __rhs)
+      operator()(const _Lhs& __lhs, const _Rhs& __rhs) const
       { return __lhs == __rhs; }
   };
+
+  template<typename _Tp, typename _FunctionObj>
+    struct bind2nd
+    {
+      const _Tp& __ref;
+      _FunctionObj __fun;
+      bind2nd(const _Tp& __refin, _FunctionObj __funin) : 
+        __ref(__refin), __fun(__funin)
+      { };
+      
+      template<typename _Tp2>
+      bool 
+      operator()(const _Tp2& __val) const
+      { return __fun(__val, __ref); }
+    };
+
+  template<typename _Tp, typename _FunctionObj>
+    inline bind2nd<_Tp, _FunctionObj>
+    equal(const _Tp& __ref, _FunctionObj __fun)
+    { return bind2nd<_Tp, _FunctionObj>(__ref, __fun); }
+
+  template<typename _Tp>
+    inline bind2nd<_Tp, equal_to>
+    equal(const _Tp& __ref)
+    { return bind2nd<_Tp, equal_to>(__ref, equal_to()); }
+
 } // namespace __ops
 } // namespace __gnu_cxx
 
diff -rNu -x '*CVS*' libstdc++-v3.so_7.clean/include/bits/stl_algobase.h libstdc++-v3/include/bits/stl_algobase.h
--- libstdc++-v3.so_7.clean/include/bits/stl_algobase.h	2005-03-09 00:47:37.225186280 +0000
+++ libstdc++-v3/include/bits/stl_algobase.h	2005-03-01 21:45:36.000000000 +0000
@@ -167,6 +167,7 @@
    *  @brief This does what you think it does.
    *  @param  a  A thing of arbitrary type.
    *  @param  b  Another thing of arbitrary type.
+   *  @param  comp  A @link s20_3_3_comparisons comparison functor@endlink.
    *  @return   The lesser of the parameters.
    *
    *  This will work on temporary expressions, since they are only evaluated
diff -rNu -x '*CVS*' libstdc++-v3.so_7.clean/include/bits/stl_algo.h libstdc++-v3/include/bits/stl_algo.h
--- libstdc++-v3.so_7.clean/include/bits/stl_algo.h	2005-02-02 00:41:45.000000000 +0000
+++ libstdc++-v3/include/bits/stl_algo.h	2005-03-09 00:45:57.410360440 +0000
@@ -151,21 +151,6 @@
 
   /**
    *  @if maint
-   *  This is an overload used by find() for the Input Iterator case.
-   *  @endif
-  */
-  template<typename _InputIterator, typename _Tp>
-    inline _InputIterator
-    __find(_InputIterator __first, _InputIterator __last,
-	 const _Tp& __val, input_iterator_tag)
-    {
-      while (__first != __last && !(*__first == __val))
-	++__first;
-      return __first;
-    }
-
-  /**
-   *  @if maint
    *  This is an overload used by find_if() for the Input Iterator case.
    *  @endif
   */
@@ -181,58 +166,6 @@
 
   /**
    *  @if maint
-   *  This is an overload used by find() for the RAI case.
-   *  @endif
-  */
-  template<typename _RandomAccessIterator, typename _Tp>
-    _RandomAccessIterator
-    __find(_RandomAccessIterator __first, _RandomAccessIterator __last,
-	 const _Tp& __val, random_access_iterator_tag)
-    {
-      typename iterator_traits<_RandomAccessIterator>::difference_type
-	__trip_count = (__last - __first) >> 2;
-
-      for ( ; __trip_count > 0 ; --__trip_count)
-	{
-	  if (*__first == __val)
-	    return __first;
-	  ++__first;
-
-	  if (*__first == __val)
-	    return __first;
-	  ++__first;
-
-	  if (*__first == __val)
-	    return __first;
-	  ++__first;
-
-	  if (*__first == __val)
-	    return __first;
-	  ++__first;
-	}
-
-      switch (__last - __first)
-	{
-	case 3:
-	  if (*__first == __val)
-	    return __first;
-	  ++__first;
-	case 2:
-	  if (*__first == __val)
-	    return __first;
-	  ++__first;
-	case 1:
-	  if (*__first == __val)
-	    return __first;
-	  ++__first;
-	case 0:
-	default:
-	  return __last;
-	}
-    }
-
-  /**
-   *  @if maint
    *  This is an overload used by find_if() for the RAI case.
    *  @endif
   */
@@ -301,8 +234,9 @@
       __glibcxx_function_requires(_EqualOpConcept<
 		typename iterator_traits<_InputIterator>::value_type, _Tp>)
       __glibcxx_requires_valid_range(__first, __last);
-      return std::__find(__first, __last, __val,
-		         std::__iterator_category(__first));
+      return std::__find_if(__first, __last, 
+			    __gnu_cxx::__ops::equal(__val),
+			    std::__iterator_category(__first));
     }
 
   /**
@@ -381,55 +315,50 @@
     }
 
   /**
-   *  @brief Count the number of copies of a value in a sequence.
+   *  @brief Count the elements of a sequence for which a predicate is true.
    *  @param  first  An input iterator.
    *  @param  last   An input iterator.
-   *  @param  value  The value to be counted.
+   *  @param  pred   A predicate.
    *  @return   The number of iterators @c i in the range @p [first,last)
-   *  for which @c *i == @p value
+   *  for which @p pred(*i) is true.
   */
-  template<typename _InputIterator, typename _Tp>
+  template<typename _InputIterator, typename _Predicate>
     typename iterator_traits<_InputIterator>::difference_type
-    count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
+    count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
     {
       // concept requirements
       __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
-      __glibcxx_function_requires(_EqualityComparableConcept<
-	    typename iterator_traits<_InputIterator>::value_type >)
-      __glibcxx_function_requires(_EqualityComparableConcept<_Tp>)
+      __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
+	    typename iterator_traits<_InputIterator>::value_type>)
       __glibcxx_requires_valid_range(__first, __last);
       typename iterator_traits<_InputIterator>::difference_type __n = 0;
       for ( ; __first != __last; ++__first)
-	if (*__first == __value)
+	if (__pred(*__first)) 
 	  ++__n;
       return __n;
     }
 
   /**
-   *  @brief Count the elements of a sequence for which a predicate is true.
+   *  @brief Count the number of copies of a value in a sequence.
    *  @param  first  An input iterator.
    *  @param  last   An input iterator.
-   *  @param  pred   A predicate.
+   *  @param  value  The value to be counted.
    *  @return   The number of iterators @c i in the range @p [first,last)
-   *  for which @p pred(*i) is true.
+   *  for which @c *i == @p value
   */
-  template<typename _InputIterator, typename _Predicate>
+  template<typename _InputIterator, typename _Tp>
     typename iterator_traits<_InputIterator>::difference_type
-    count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
+    count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
     {
       // concept requirements
-      __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
-      __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
-	    typename iterator_traits<_InputIterator>::value_type>)
+      __glibcxx_function_requires(_EqualityComparableConcept<
+	    typename iterator_traits<_InputIterator>::value_type >)
+      __glibcxx_function_requires(_EqualityComparableConcept<_Tp>)
       __glibcxx_requires_valid_range(__first, __last);
-      typename iterator_traits<_InputIterator>::difference_type __n = 0;
-      for ( ; __first != __last; ++__first)
-	if (__pred(*__first))
-	  ++__n;
-      return __n;
+      return std::count_if(__first, __last, __gnu_cxx::__ops::equal(__value));
     }
 
- /**
+  /**
    *  @brief Search a sequence for a matching sub-sequence using a predicate.
    *  @param  first1     A forward iterator.
    *  @param  last1      A forward iterator.
@@ -750,37 +679,6 @@
     }
 
   /**
-   *  @brief Replace each occurrence of one value in a sequence with another
-   *         value.
-   *  @param  first      A forward iterator.
-   *  @param  last       A forward iterator.
-   *  @param  old_value  The value to be replaced.
-   *  @param  new_value  The replacement value.
-   *  @return   replace() returns no value.
-   *
-   *  For each iterator @c i in the range @p [first,last) if @c *i ==
-   *  @p old_value then the assignment @c *i = @p new_value is performed.
-  */
-  template<typename _ForwardIterator, typename _Tp>
-    void
-    replace(_ForwardIterator __first, _ForwardIterator __last,
-	    const _Tp& __old_value, const _Tp& __new_value)
-    {
-      // concept requirements
-      __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
-				  _ForwardIterator>)
-      __glibcxx_function_requires(_EqualOpConcept<
-	    typename iterator_traits<_ForwardIterator>::value_type, _Tp>)
-      __glibcxx_function_requires(_ConvertibleConcept<_Tp,
-	    typename iterator_traits<_ForwardIterator>::value_type>)
-      __glibcxx_requires_valid_range(__first, __last);
-
-      for ( ; __first != __last; ++__first)
-	if (*__first == __old_value)
-	  *__first = __new_value;
-    }
-
-  /**
    *  @brief Replace each value in a sequence for which a predicate returns
    *         true with another value.
    *  @param  first      A forward iterator.
@@ -812,36 +710,27 @@
     }
 
   /**
-   *  @brief Copy a sequence, replacing each element of one value with another
+   *  @brief Replace each occurrence of one value in a sequence with another
    *         value.
-   *  @param  first      An input iterator.
-   *  @param  last       An input iterator.
-   *  @param  result     An output iterator.
+   *  @param  first      A forward iterator.
+   *  @param  last       A forward iterator.
    *  @param  old_value  The value to be replaced.
    *  @param  new_value  The replacement value.
-   *  @return   The end of the output sequence, @p result+(last-first).
+   *  @return   replace() returns no value.
    *
-   *  Copies each element in the input range @p [first,last) to the
-   *  output range @p [result,result+(last-first)) replacing elements
-   *  equal to @p old_value with @p new_value.
+   *  For each iterator @c i in the range @p [first,last) if @c *i ==
+   *  @p old_value then the assignment @c *i = @p new_value is performed.
   */
-  template<typename _InputIterator, typename _OutputIterator, typename _Tp>
-    _OutputIterator
-    replace_copy(_InputIterator __first, _InputIterator __last,
-		 _OutputIterator __result,
-		 const _Tp& __old_value, const _Tp& __new_value)
+  template<typename _ForwardIterator, typename _Tp>
+    void
+    replace(_ForwardIterator __first, _ForwardIterator __last,
+	    const _Tp& __old_value, const _Tp& __new_value)
     {
       // concept requirements
-      __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
-      __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
-	    typename iterator_traits<_InputIterator>::value_type>)
       __glibcxx_function_requires(_EqualOpConcept<
-	    typename iterator_traits<_InputIterator>::value_type, _Tp>)
-      __glibcxx_requires_valid_range(__first, __last);
-
-      for ( ; __first != __last; ++__first, ++__result)
-	*__result = *__first == __old_value ? __new_value : *__first;
-      return __result;
+	    typename iterator_traits<_ForwardIterator>::value_type, _Tp>)
+      std::replace_if(__first, __last, __gnu_cxx::__ops::equal(__old_value),
+		      __new_value);
     }
 
   /**
@@ -874,10 +763,43 @@
       __glibcxx_requires_valid_range(__first, __last);
 
       for ( ; __first != __last; ++__first, ++__result)
-	*__result = __pred(*__first) ? __new_value : *__first;
+	{
+	  if(__pred(*__first))
+	    *__result = __new_value;
+	  else
+	    *__result = *__first;
+	}
       return __result;
     }
 
+ /**
+   *  @brief Copy a sequence, replacing each element of one value with another
+   *         value.
+   *  @param  first      An input iterator.
+   *  @param  last       An input iterator.
+   *  @param  result     An output iterator.
+   *  @param  old_value  The value to be replaced.
+   *  @param  new_value  The replacement value.
+   *  @return   The end of the output sequence, @p result+(last-first).
+   *
+   *  Copies each element in the input range @p [first,last) to the
+   *  output range @p [result,result+(last-first)) replacing elements
+   *  equal to @p old_value with @p new_value.
+  */
+  template<typename _InputIterator, typename _OutputIterator, typename _Tp>
+    _OutputIterator
+    replace_copy(_InputIterator __first, _InputIterator __last,
+		 _OutputIterator __result,
+		 const _Tp& __old_value, const _Tp& __new_value)
+    {
+      // concept requirements
+      __glibcxx_function_requires(_EqualOpConcept<
+	    typename iterator_traits<_InputIterator>::value_type, _Tp>)
+      return std::replace_copy_if(__first, __last, __result,
+				  __gnu_cxx::__ops::equal(__old_value),
+				  __new_value);
+    }
+
   /**
    *  @brief Assign the result of a function object to each value in a
    *         sequence.
@@ -930,41 +852,6 @@
     }
 
   /**
-   *  @brief Copy a sequence, removing elements of a given value.
-   *  @param  first   An input iterator.
-   *  @param  last    An input iterator.
-   *  @param  result  An output iterator.
-   *  @param  value   The value to be removed.
-   *  @return   An iterator designating the end of the resulting sequence.
-   *
-   *  Copies each element in the range @p [first,last) not equal to @p value
-   *  to the range beginning at @p result.
-   *  remove_copy() is stable, so the relative order of elements that are
-   *  copied is unchanged.
-  */
-  template<typename _InputIterator, typename _OutputIterator, typename _Tp>
-    _OutputIterator
-    remove_copy(_InputIterator __first, _InputIterator __last,
-		_OutputIterator __result, const _Tp& __value)
-    {
-      // concept requirements
-      __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
-      __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
-	    typename iterator_traits<_InputIterator>::value_type>)
-      __glibcxx_function_requires(_EqualOpConcept<
-	    typename iterator_traits<_InputIterator>::value_type, _Tp>)
-      __glibcxx_requires_valid_range(__first, __last);
-
-      for ( ; __first != __last; ++__first)
-	if (!(*__first == __value))
-	  {
-	    *__result = *__first;
-	    ++__result;
-	  }
-      return __result;
-    }
-
-  /**
    *  @brief Copy a sequence, removing elements for which a predicate is true.
    *  @param  first   An input iterator.
    *  @param  last    An input iterator.
@@ -1001,39 +888,29 @@
       return __result;
     }
 
-  /**
-   *  @brief Remove elements from a sequence.
-   *  @param  first  An input iterator.
-   *  @param  last   An input iterator.
-   *  @param  value  The value to be removed.
+ /**
+   *  @brief Copy a sequence, removing elements of a given value.
+   *  @param  first   An input iterator.
+   *  @param  last    An input iterator.
+   *  @param  result  An output iterator.
+   *  @param  value   The value to be removed.
    *  @return   An iterator designating the end of the resulting sequence.
    *
-   *  All elements equal to @p value are removed from the range
-   *  @p [first,last).
-   *
-   *  remove() is stable, so the relative order of elements that are
-   *  not removed is unchanged.
-   *
-   *  Elements between the end of the resulting sequence and @p last
-   *  are still present, but their value is unspecified.
+   *  Copies each element in the range @p [first,last) not equal to @p value
+   *  to the range beginning at @p result.
+   *  remove_copy() is stable, so the relative order of elements that are
+   *  copied is unchanged.
   */
-  template<typename _ForwardIterator, typename _Tp>
-    _ForwardIterator
-    remove(_ForwardIterator __first, _ForwardIterator __last,
-	   const _Tp& __value)
+  template<typename _InputIterator, typename _OutputIterator, typename _Tp>
+    _OutputIterator
+    remove_copy(_InputIterator __first, _InputIterator __last,
+		_OutputIterator __result, const _Tp& __value)
     {
       // concept requirements
-      __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
-				  _ForwardIterator>)
       __glibcxx_function_requires(_EqualOpConcept<
-	    typename iterator_traits<_ForwardIterator>::value_type, _Tp>)
-      __glibcxx_requires_valid_range(__first, __last);
-
-      __first = std::find(__first, __last, __value);
-      _ForwardIterator __i = __first;
-      return __first == __last ? __first
-			       : std::remove_copy(++__i, __last,
-						  __first, __value);
+	    typename iterator_traits<_InputIterator>::value_type, _Tp>)
+      return std::remove_copy_if(__first, __value, __result,
+				 __gnu_cxx::__ops::equal(__value));
     }
 
   /**
@@ -1072,6 +949,34 @@
     }
 
   /**
+   *  @brief Remove elements from a sequence.
+   *  @param  first  An input iterator.
+   *  @param  last   An input iterator.
+   *  @param  value  The value to be removed.
+   *  @return   An iterator designating the end of the resulting sequence.
+   *
+   *  All elements equal to @p value are removed from the range
+   *  @p [first,last).
+   *
+   *  remove() is stable, so the relative order of elements that are
+   *  not removed is unchanged.
+   *
+   *  Elements between the end of the resulting sequence and @p last
+   *  are still present, but their value is unspecified.
+  */
+  template<typename _ForwardIterator, typename _Tp>
+    _ForwardIterator
+    remove(_ForwardIterator __first, _ForwardIterator __last,
+	   const _Tp& __value)
+    {
+      // concept requirements
+      __glibcxx_function_requires(_EqualOpConcept<
+	    typename iterator_traits<_ForwardIterator>::value_type, _Tp>)
+      return std::remove_if(__first, __last,
+			    __gnu_cxx::__ops::equal(__value));
+    }
+
+  /**
    *  @if maint
    *  This is an uglified
    *  unique_copy(_InputIterator, _InputIterator, _OutputIterator,
diff -rNu -x '*CVS*' libstdc++-v3.so_7.clean/testsuite/25_algorithms/count/1.cc libstdc++-v3/testsuite/25_algorithms/count/1.cc
--- libstdc++-v3.so_7.clean/testsuite/25_algorithms/count/1.cc	1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/25_algorithms/count/1.cc	2005-03-08 20:53:43.000000000 +0000
@@ -0,0 +1,58 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 25.1.6 count
+
+#include <algorithm>
+#include <testsuite_hooks.h>
+#include <testsuite_iterators.h>
+
+using __gnu_test::test_container;
+using __gnu_test::input_iterator_wrapper;
+
+typedef test_container<int, input_iterator_wrapper> Container;
+int array[] = {0, 0, 0, 1, 0, 1};
+
+void
+test1()
+{
+  Container con(array, array);
+  VERIFY(std::count(con.begin(), con.end(), 1) == 0);
+}
+
+void
+test2()
+{
+  Container con(array, array + 1);
+  VERIFY(std::count(con.begin(), con.end(), 1) == 0);
+}
+
+void
+test3()
+{
+  Container con(array, array + 6);
+  VERIFY(std::count(con.begin(), con.end(), 1) == 2);
+}
+
+int 
+main()
+{
+  test1();
+  test2();
+  test3();
+}
diff -rNu -x '*CVS*' libstdc++-v3.so_7.clean/testsuite/25_algorithms/count/check_type.cc libstdc++-v3/testsuite/25_algorithms/count/check_type.cc
--- libstdc++-v3.so_7.clean/testsuite/25_algorithms/count/check_type.cc	1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/25_algorithms/count/check_type.cc	2005-03-08 20:51:01.000000000 +0000
@@ -0,0 +1,42 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 25.1.2 find_if
+
+// { dg-do compile }
+
+#include <algorithm>
+#include <testsuite_iterators.h>
+
+struct X { };
+
+struct Y { };
+
+using __gnu_test::input_iterator_wrapper;
+
+bool
+operator==(const X&, const Y&)
+{ return true; }
+
+typedef std::iterator_traits<input_iterator_wrapper<X> >::difference_type
+	diff_type;
+
+diff_type
+test1(input_iterator_wrapper<X>& begin,
+      input_iterator_wrapper<X>& end)
+{ return std::count(begin, end, Y()); }
diff -rNu -x '*CVS*' libstdc++-v3.so_7.clean/testsuite/25_algorithms/count_if/1.cc libstdc++-v3/testsuite/25_algorithms/count_if/1.cc
--- libstdc++-v3.so_7.clean/testsuite/25_algorithms/count_if/1.cc	1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/25_algorithms/count_if/1.cc	2005-03-08 20:47:55.000000000 +0000
@@ -0,0 +1,65 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 25.1.6 count_if
+
+#include <algorithm>
+#include <testsuite_hooks.h>
+#include <testsuite_iterators.h>
+
+using __gnu_test::test_container;
+using __gnu_test::input_iterator_wrapper;
+
+typedef test_container<int, input_iterator_wrapper> Container;
+int array[] = {0, 0, 0, 1, 0, 1};
+
+bool
+predicate(const int& i) 
+{ return i == 1; }
+
+void
+test1()
+{
+  Container con(array, array);
+  VERIFY(std::count_if(con.begin(), con.end(), 
+		       predicate) == 0);
+}
+
+void
+test2()
+{
+  Container con(array, array + 1);
+  VERIFY(std::count_if(con.begin(), con.end(), 
+		       predicate) == 0);
+}
+
+void
+test3()
+{
+  Container con(array, array + 6);
+  VERIFY(std::count_if(con.begin(), con.end(),
+		       predicate) == 2);
+}
+
+int 
+main()
+{
+  test1();
+  test2();
+  test3();
+}
diff -rNu -x '*CVS*' libstdc++-v3.so_7.clean/testsuite/25_algorithms/count_if/check_type.cc libstdc++-v3/testsuite/25_algorithms/count_if/check_type.cc
--- libstdc++-v3.so_7.clean/testsuite/25_algorithms/count_if/check_type.cc	1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/25_algorithms/count_if/check_type.cc	2005-03-08 20:45:46.000000000 +0000
@@ -0,0 +1,52 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 25.1.2 find_if
+
+// { dg-do compile }
+
+#include <algorithm>
+#include <testsuite_iterators.h>
+
+struct X { };
+
+using __gnu_test::input_iterator_wrapper;
+
+bool
+pred_function(const X&)
+{ return true; }
+
+struct pred_obj
+{
+  bool 
+  operator()(const X&)
+  { return true; }
+};
+
+typedef std::iterator_traits<input_iterator_wrapper<X> >::difference_type
+	diff_type;
+
+diff_type
+test1(input_iterator_wrapper<X>& begin,
+      input_iterator_wrapper<X>& end)
+{ return std::count_if(begin, end, pred_function); }
+
+diff_type
+test2(input_iterator_wrapper<X>& begin,
+      input_iterator_wrapper<X>& end)
+{ return std::count_if(begin, end, pred_obj()); }
diff -rNu -x '*CVS*' libstdc++-v3.so_7.clean/testsuite/25_algorithms/find/1.cc libstdc++-v3/testsuite/25_algorithms/find/1.cc
--- libstdc++-v3.so_7.clean/testsuite/25_algorithms/find/1.cc	1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/25_algorithms/find/1.cc	2005-03-08 20:28:55.000000000 +0000
@@ -0,0 +1,58 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 25.1.2 find
+
+#include <algorithm>
+#include <testsuite_hooks.h>
+#include <testsuite_iterators.h>
+
+using __gnu_test::test_container;
+using __gnu_test::input_iterator_wrapper;
+
+typedef test_container<int, input_iterator_wrapper> Container;
+int array[] = {0, 0, 0, 1, 0, 1};
+
+void
+test1()
+{
+  Container con(array, array);
+  VERIFY(std::find(con.begin(), con.end(), 1).ptr == array);
+}
+
+void
+test2()
+{
+  Container con(array, array + 1);
+  VERIFY(std::find(con.begin(), con.end(), 1).ptr == array + 1);
+}
+
+void
+test3()
+{
+  Container con(array, array + 6);
+  VERIFY(std::find(con.begin(), con.end(), 1).ptr == array + 3);
+}
+
+int 
+main()
+{
+  test1();
+  test2();
+  test3();
+}
diff -rNu -x '*CVS*' libstdc++-v3.so_7.clean/testsuite/25_algorithms/find/check_type.cc libstdc++-v3/testsuite/25_algorithms/find/check_type.cc
--- libstdc++-v3.so_7.clean/testsuite/25_algorithms/find/check_type.cc	1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/25_algorithms/find/check_type.cc	2005-03-08 20:33:46.000000000 +0000
@@ -0,0 +1,38 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 25.1.2 find
+
+// { dg-do compile }
+
+#include <algorithm>
+#include <testsuite_iterators.h>
+
+using __gnu_test::input_iterator_wrapper;
+
+struct Lhs { };
+struct Rhs { };
+
+bool
+operator==(const Lhs&, const Rhs&)
+{ return true; }
+
+input_iterator_wrapper<Lhs>
+test1(input_iterator_wrapper<Lhs>& begin,
+      input_iterator_wrapper<Lhs>& end, Rhs& val)
+{ return std::find(begin, end, val); }
diff -rNu -x '*CVS*' libstdc++-v3.so_7.clean/testsuite/25_algorithms/find_if/1.cc libstdc++-v3/testsuite/25_algorithms/find_if/1.cc
--- libstdc++-v3.so_7.clean/testsuite/25_algorithms/find_if/1.cc	1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/25_algorithms/find_if/1.cc	2005-03-08 20:18:22.000000000 +0000
@@ -0,0 +1,65 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 25.1.2 find_if
+
+#include <algorithm>
+#include <testsuite_hooks.h>
+#include <testsuite_iterators.h>
+
+using __gnu_test::test_container;
+using __gnu_test::input_iterator_wrapper;
+
+typedef test_container<int, input_iterator_wrapper> Container;
+int array[] = {0, 0, 0, 1, 0, 1};
+
+bool
+predicate(const int& i) 
+{ return i == 1; }
+
+void
+test1()
+{
+  Container con(array, array);
+  VERIFY(std::find_if(con.begin(), con.end(), 
+		      predicate).ptr == array);
+}
+
+void
+test2()
+{
+  Container con(array, array + 1);
+  VERIFY(std::find_if(con.begin(), con.end(), 
+		      predicate).ptr == array + 1);
+}
+
+void
+test3()
+{
+  Container con(array, array + 6);
+  VERIFY(std::find_if(con.begin(), con.end(),
+		      predicate).ptr == array + 3);
+}
+
+int 
+main()
+{
+  test1();
+  test2();
+  test3();
+}
diff -rNu -x '*CVS*' libstdc++-v3.so_7.clean/testsuite/25_algorithms/find_if/check_type.cc libstdc++-v3/testsuite/25_algorithms/find_if/check_type.cc
--- libstdc++-v3.so_7.clean/testsuite/25_algorithms/find_if/check_type.cc	1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/25_algorithms/find_if/check_type.cc	2005-03-08 20:15:00.000000000 +0000
@@ -0,0 +1,49 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 25.1.2 find_if
+
+// { dg-do compile }
+
+#include <algorithm>
+#include <testsuite_iterators.h>
+
+struct X { };
+
+using __gnu_test::input_iterator_wrapper;
+
+bool
+pred_function(const X&)
+{ return true; }
+
+struct pred_obj
+{
+  bool 
+  operator()(const X&)
+  { return true; }
+};
+
+input_iterator_wrapper<X>
+test1(input_iterator_wrapper<X>& begin,
+      input_iterator_wrapper<X>& end)
+{ return std::find_if(begin, end, pred_function); }
+
+input_iterator_wrapper<X>
+test2(input_iterator_wrapper<X>& begin,
+      input_iterator_wrapper<X>& end)
+{ return std::find_if(begin, end, pred_obj()); }
diff -rNu -x '*CVS*' libstdc++-v3.so_7.clean/testsuite/25_algorithms/remove/1.cc libstdc++-v3/testsuite/25_algorithms/remove/1.cc
--- libstdc++-v3.so_7.clean/testsuite/25_algorithms/remove/1.cc	1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/25_algorithms/remove/1.cc	2005-03-09 00:13:02.432602696 +0000
@@ -0,0 +1,63 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 25.2.4 remove
+
+#include <algorithm>
+#include <testsuite_hooks.h>
+#include <testsuite_iterators.h>
+
+using __gnu_test::test_container;
+using __gnu_test::forward_iterator_wrapper;
+
+typedef test_container<int, forward_iterator_wrapper> Container; 
+
+void
+test1()
+{
+  int array[1];
+  Container con(array, array);
+  VERIFY(std::remove(con.begin(), con.end(), 1).ptr == array);
+}
+
+void
+test2()
+{
+  int array[] = {1};
+  Container con(array, array + 1);
+  VERIFY(std::remove(con.begin(), con.end(), 0).ptr == array + 1);
+  VERIFY(std::remove(con.begin(), con.end(), 1).ptr == array);
+}
+
+void
+test3()
+{
+  int array[] = {0, 1, 0, 1, 0, 0, 1, 1};
+  Container con(array, array + 8);
+  VERIFY(std::remove(con.begin(), con.end(), 1).ptr == array + 4);
+  VERIFY(array[0] == 0 && array[1] == 0 && array[2] == 0 && 
+	 array[3] == 0);
+}
+
+int
+main()
+{
+  test1();
+  test2();
+  test3();
+}
diff -rNu -x '*CVS*' libstdc++-v3.so_7.clean/testsuite/25_algorithms/remove/check_type.cc libstdc++-v3/testsuite/25_algorithms/remove/check_type.cc
--- libstdc++-v3.so_7.clean/testsuite/25_algorithms/remove/check_type.cc	1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/25_algorithms/remove/check_type.cc	2005-03-09 00:11:43.056669672 +0000
@@ -0,0 +1,39 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 25.2.7 Remove
+
+// { dg-do compile }
+
+#include <algorithm>
+#include <testsuite_iterators.h>
+
+using __gnu_test::forward_iterator_wrapper;
+
+struct X { };
+
+struct Y { };
+
+bool
+operator==(const X&, const Y&)
+{ return true; }
+
+forward_iterator_wrapper<X>
+test1(forward_iterator_wrapper<X>& begin,
+      forward_iterator_wrapper<X>& end, const Y& val)
+{ return std::remove(begin, end, val); }
diff -rNu -x '*CVS*' libstdc++-v3.so_7.clean/testsuite/25_algorithms/remove_if/1.cc libstdc++-v3/testsuite/25_algorithms/remove_if/1.cc
--- libstdc++-v3.so_7.clean/testsuite/25_algorithms/remove_if/1.cc	1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/25_algorithms/remove_if/1.cc	2005-03-09 00:11:06.929161888 +0000
@@ -0,0 +1,63 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 25.2.4 remove
+
+#include <algorithm>
+#include <testsuite_hooks.h>
+#include <testsuite_iterators.h>
+
+using __gnu_test::test_container;
+using __gnu_test::forward_iterator_wrapper;
+
+typedef test_container<int, forward_iterator_wrapper> Container; 
+
+void
+test1()
+{
+  int array[1];
+  Container con(array, array);
+  VERIFY(std::remove(con.begin(), con.end(), 1).ptr == array);
+}
+
+void
+test2()
+{
+  int array[] = {1};
+  Container con(array, array + 1);
+  VERIFY(std::remove(con.begin(), con.end(), 0).ptr == array + 1);
+  VERIFY(std::remove(con.begin(), con.end(), 1).ptr == array);
+}
+
+void
+test3()
+{
+  int array[] = {0, 1, 0, 1, 0, 0, 1, 1};
+  Container con(array, array + 8);
+  VERIFY(std::remove(con.begin(), con.end(), 1).ptr == array + 4);
+  VERIFY(array[0] == 0 && array[1] == 0 && array[2] == 0 &&
+         array[3] == 0);
+}
+
+int
+main()
+{
+  test1();
+  test2();
+  test3();
+}
diff -rNu -x '*CVS*' libstdc++-v3.so_7.clean/testsuite/25_algorithms/remove_if/check_type.cc libstdc++-v3/testsuite/25_algorithms/remove_if/check_type.cc
--- libstdc++-v3.so_7.clean/testsuite/25_algorithms/remove_if/check_type.cc	1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/25_algorithms/remove_if/check_type.cc	2005-03-09 00:08:12.864623720 +0000
@@ -0,0 +1,50 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 25.2.7 Remove_if
+
+// { dg-do compile }
+
+#include <algorithm>
+#include <testsuite_iterators.h>
+
+using __gnu_test::forward_iterator_wrapper;
+
+struct X { };
+
+bool
+pred_fn(const X&)
+{ return true; }
+
+struct pred_obj
+{
+  bool
+  operator()(const X&) const
+  { return true; }
+};
+
+forward_iterator_wrapper<X>
+test1(forward_iterator_wrapper<X>& begin,
+      forward_iterator_wrapper<X>& end)
+{ return std::remove_if(begin, end, pred_fn); }
+
+forward_iterator_wrapper<X>
+test2(forward_iterator_wrapper<X>& begin,
+      forward_iterator_wrapper<X>& end)
+{ return std::remove_if(begin, end, pred_obj()); }
+
diff -rNu -x '*CVS*' libstdc++-v3.so_7.clean/testsuite/25_algorithms/replace/1.cc libstdc++-v3/testsuite/25_algorithms/replace/1.cc
--- libstdc++-v3.so_7.clean/testsuite/25_algorithms/replace/1.cc	1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/25_algorithms/replace/1.cc	2005-03-08 21:10:43.000000000 +0000
@@ -0,0 +1,61 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 25.2.4 replace
+
+#include <algorithm>
+#include <testsuite_hooks.h>
+#include <testsuite_iterators.h>
+
+using __gnu_test::test_container;
+using __gnu_test::forward_iterator_wrapper;
+
+typedef test_container<int, forward_iterator_wrapper> Container; 
+int array[] = {0, 0, 0, 1, 0, 1};
+
+void
+test1()
+{
+  Container con(array, array);
+  std::replace(con.begin(), con.end(), 1, 1);
+}
+
+void
+test2()
+{
+  Container con(array, array + 1);
+  std::replace(con.begin(), con.end(), 0, 1);
+  VERIFY(array[0] == 1);
+}
+
+void
+test3()
+{
+  Container con(array, array + 6);
+  std::replace(con.begin(), con.end(), 1, 2);
+  VERIFY(array[0] == 2 && array[1] == 0 && array[2] == 0 &&
+         array[3] == 2 && array[4] == 0 && array[5] == 2);
+}
+
+int 
+main()
+{
+  test1();
+  test2();
+  test3();
+}
diff -rNu -x '*CVS*' libstdc++-v3.so_7.clean/testsuite/25_algorithms/replace/check_type.cc libstdc++-v3/testsuite/25_algorithms/replace/check_type.cc
--- libstdc++-v3.so_7.clean/testsuite/25_algorithms/replace/check_type.cc	1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/25_algorithms/replace/check_type.cc	2005-03-08 21:39:12.000000000 +0000
@@ -0,0 +1,38 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 25.2.4 Replace
+
+// { dg-do compile }
+
+#include <algorithm>
+#include <testsuite_iterators.h>
+
+using __gnu_test::forward_iterator_wrapper;
+
+struct X { };
+
+bool
+operator==(const X&, const X&)
+{ return true; }
+
+void
+test1(forward_iterator_wrapper<X>& begin,
+      forward_iterator_wrapper<X>& end, const X& old_val,
+      const X& new_val)
+{ return std::replace(begin, end, old_val, new_val); }
diff -rNu -x '*CVS*' libstdc++-v3.so_7.clean/testsuite/25_algorithms/replace_copy/1.cc libstdc++-v3/testsuite/25_algorithms/replace_copy/1.cc
--- libstdc++-v3.so_7.clean/testsuite/25_algorithms/replace_copy/1.cc	1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/25_algorithms/replace_copy/1.cc	2005-03-08 22:05:27.000000000 +0000
@@ -0,0 +1,72 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 25.2.4 replace_copy
+
+#include <algorithm>
+#include <testsuite_hooks.h>
+#include <testsuite_iterators.h>
+
+using __gnu_test::test_container;
+using __gnu_test::input_iterator_wrapper;
+using __gnu_test::output_iterator_wrapper;
+
+typedef test_container<int, input_iterator_wrapper> Icontainer; 
+typedef test_container<int, output_iterator_wrapper> Ocontainer;
+int array[] = {0, 0, 0, 1, 0, 1};
+
+void
+test1()
+{
+  int out[1];
+  Icontainer in_con(array, array);
+  Ocontainer out_con(out, out);
+  VERIFY(std::replace_copy(in_con.begin(), in_con.end(), 
+	                   out_con.begin(), 1, 1).ptr == out);
+}
+
+void
+test2()
+{
+  int out[1];
+  Icontainer in_con(array, array + 1);
+  Ocontainer out_con(out, out + 1);
+  VERIFY(std::replace_copy(in_con.begin(), in_con.end(), 
+			   out_con.begin(), 0, 1).ptr == out + 1);
+  VERIFY(out[0] == 1);
+}
+
+void
+test3()
+{
+  int out[6];
+  Icontainer in_con(array, array + 6);
+  Ocontainer out_con(out, out + 6);
+  VERIFY(std::replace_copy(in_con.begin(), in_con.end(),
+			   out_con.begin(), 1, 2).ptr == out + 6);
+  VERIFY(out[0] == 0 && out[1] == 0 && out[2] == 0 &&
+         out[3] == 2 && out[4] == 0 && out[5] == 2);
+}
+
+int 
+main()
+{
+  test1();
+  test2();
+  test3();
+}
diff -rNu -x '*CVS*' libstdc++-v3.so_7.clean/testsuite/25_algorithms/replace_copy/check_type.cc libstdc++-v3/testsuite/25_algorithms/replace_copy/check_type.cc
--- libstdc++-v3.so_7.clean/testsuite/25_algorithms/replace_copy/check_type.cc	1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/25_algorithms/replace_copy/check_type.cc	2005-03-08 23:03:37.000000000 +0000
@@ -0,0 +1,56 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 25.2.4 replace_copy
+
+// { dg-do compile }
+
+#include <algorithm>
+#include <testsuite_iterators.h>
+
+using __gnu_test::input_iterator_wrapper;
+using __gnu_test::output_iterator_wrapper;
+
+struct X { };
+
+struct Y { };
+
+struct Z
+{
+  Z&
+  operator=(const X&)
+  { }
+
+  Z&
+  operator=(const Y&)
+  { }
+};
+
+bool
+operator==(const X&, const Y&)
+{ return true; }
+
+output_iterator_wrapper<Z>
+test1(input_iterator_wrapper<X>& begin,
+      input_iterator_wrapper<X>& end,
+      output_iterator_wrapper<Z>& output,
+      const Y& old_val, const Y& new_val)
+{ 
+  return std::replace_copy(begin, end, output, old_val, 
+			   new_val); 
+}
diff -rNu -x '*CVS*' libstdc++-v3.so_7.clean/testsuite/25_algorithms/replace_copy_if/1.cc libstdc++-v3/testsuite/25_algorithms/replace_copy_if/1.cc
--- libstdc++-v3.so_7.clean/testsuite/25_algorithms/replace_copy_if/1.cc	1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/25_algorithms/replace_copy_if/1.cc	2005-03-08 23:34:33.385631192 +0000
@@ -0,0 +1,76 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 25.2.4 replace_copy_if
+
+#include <algorithm>
+#include <testsuite_hooks.h>
+#include <testsuite_iterators.h>
+
+using __gnu_test::test_container;
+using __gnu_test::input_iterator_wrapper;
+using __gnu_test::output_iterator_wrapper;
+
+typedef test_container<int, input_iterator_wrapper> Icontainer; 
+typedef test_container<int, output_iterator_wrapper> Ocontainer;
+int array[] = {0, 0, 0, 1, 0, 1};
+
+bool
+pred(int i)
+{ return i == 1; }
+
+void
+test1()
+{
+  int out[1];
+  Icontainer in_con(array, array);
+  Ocontainer out_con(out, out);
+  VERIFY(std::replace_copy_if(in_con.begin(), in_con.end(), 
+	                      out_con.begin(), pred, 1).ptr == out);
+}
+
+void
+test2()
+{
+  int out[1];
+  Icontainer in_con(array, array + 1);
+  Ocontainer out_con(out, out + 1);
+  VERIFY(std::replace_copy_if(in_con.begin(), in_con.end(), 
+			      out_con.begin(), pred, 2).ptr == out + 1);
+  VERIFY(out[0] == 0);
+}
+
+void
+test3()
+{
+  int out[6];
+  Icontainer in_con(array, array + 6);
+  Ocontainer out_con(out, out + 6);
+  VERIFY(std::replace_copy_if(in_con.begin(), in_con.end(),
+			      out_con.begin(), pred, 2).ptr == out + 6);
+  VERIFY(out[0] == 0 && out[1] == 0 && out[2] == 0 &&
+         out[3] == 2 && out[4] == 0 && out[5] == 2);
+}
+
+int 
+main()
+{
+  test1();
+  test2();
+  test3();
+}
diff -rNu -x '*CVS*' libstdc++-v3.so_7.clean/testsuite/25_algorithms/replace_copy_if/check_type.cc libstdc++-v3/testsuite/25_algorithms/replace_copy_if/check_type.cc
--- libstdc++-v3.so_7.clean/testsuite/25_algorithms/replace_copy_if/check_type.cc	1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/25_algorithms/replace_copy_if/check_type.cc	2005-03-08 23:25:16.049359184 +0000
@@ -0,0 +1,52 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 25.2.4 replace_copy_if
+
+// { dg-do compile }
+
+#include <algorithm>
+#include <testsuite_iterators.h>
+
+using __gnu_test::input_iterator_wrapper;
+using __gnu_test::output_iterator_wrapper;
+
+struct X { };
+
+struct Y { };
+
+struct Z
+{
+  Z(const X&) { }
+  Z(const Y&) { }
+};
+
+bool
+predicate(const X&)
+{ return true; }
+
+
+output_iterator_wrapper<X>
+test1(input_iterator_wrapper<X>& begin,
+      input_iterator_wrapper<X>& end,
+      output_iterator_wrapper<X>& output,
+      const X& new_val)
+{ 
+  return std::replace_copy_if(begin, end, output, predicate, 
+			      new_val); 
+}
diff -rNu -x '*CVS*' libstdc++-v3.so_7.clean/testsuite/25_algorithms/replace_if/1.cc libstdc++-v3/testsuite/25_algorithms/replace_if/1.cc
--- libstdc++-v3.so_7.clean/testsuite/25_algorithms/replace_if/1.cc	1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/25_algorithms/replace_if/1.cc	2005-03-08 21:19:07.000000000 +0000
@@ -0,0 +1,65 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 25.2.4 replace_if
+
+#include <algorithm>
+#include <testsuite_hooks.h>
+#include <testsuite_iterators.h>
+
+using __gnu_test::test_container;
+using __gnu_test::forward_iterator_wrapper;
+
+typedef test_container<int, forward_iterator_wrapper> Container; 
+int array[] = {1, 0, 0, 1, 0, 1};
+
+bool
+predicate(const int& i)
+{ return i == 1; }
+
+void
+test1()
+{
+  Container con(array, array);
+  std::replace_if(con.begin(), con.end(), predicate, 1);
+}
+
+void
+test2()
+{
+  Container con(array, array + 1);
+  std::replace_if(con.begin(), con.end(), predicate, 2);
+  VERIFY(array[0] == 2);
+}
+
+void
+test3()
+{
+  Container con(array, array + 6);
+  std::replace_if(con.begin(), con.end(), predicate, 3);
+  VERIFY(array[0] == 2 && array[1] == 0 && array[2] == 0 &&
+         array[3] == 3 && array[4] == 0 && array[5] == 3);
+}
+
+int 
+main()
+{
+  test1();
+  test2();
+  test3();
+}
diff -rNu -x '*CVS*' libstdc++-v3.so_7.clean/testsuite/25_algorithms/replace_if/check_type.cc libstdc++-v3/testsuite/25_algorithms/replace_if/check_type.cc
--- libstdc++-v3.so_7.clean/testsuite/25_algorithms/replace_if/check_type.cc	1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/25_algorithms/replace_if/check_type.cc	2005-03-08 21:16:53.000000000 +0000
@@ -0,0 +1,52 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 25.2.4 replace_if
+
+// { dg-do compile }
+
+#include <algorithm>
+#include <testsuite_iterators.h>
+
+using __gnu_test::forward_iterator_wrapper;
+
+struct X { };
+
+bool
+pred_fn(const X&)
+{ return true; }
+
+struct pred_obj
+{
+  bool
+  operator()(const X&)
+  { return true; }
+};
+
+
+void
+test1(forward_iterator_wrapper<X>& begin,
+      forward_iterator_wrapper<X>& end, const X& new_val)
+{ return std::replace_if(begin, end, pred_fn, new_val); }
+
+void
+test2(forward_iterator_wrapper<X>& begin,
+      forward_iterator_wrapper<X>& end, const X& new_val)
+{ return std::replace_if(begin, end, pred_obj(), new_val); }
+
+
diff -rNu -x '*CVS*' libstdc++-v3.so_7.clean/testsuite/testsuite_iterators.h libstdc++-v3/testsuite/testsuite_iterators.h
--- libstdc++-v3.so_7.clean/testsuite/testsuite_iterators.h	2005-02-01 10:59:55.000000000 +0000
+++ libstdc++-v3/testsuite/testsuite_iterators.h	2005-03-08 22:50:59.462007984 +0000
@@ -98,7 +98,7 @@
 
       template<class U>
       void
-      operator=(U& new_val)
+      operator=(const U& new_val)
       {
 	ITERATOR_VERIFY(SharedInfo->writtento[ptr - SharedInfo->first] == 0);
 	SharedInfo->writtento[ptr - SharedInfo->first] = 1;

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