stl_algo.h (search_n): Improve the previous fix as suggested by Martin.
authorPaolo Carlini <pcarlini@unitus.it>
Mon, 29 Sep 2003 19:43:04 +0000 (21:43 +0200)
committerPaolo Carlini <paolo@gcc.gnu.org>
Mon, 29 Sep 2003 19:43:04 +0000 (19:43 +0000)
2003-09-29  Paolo Carlini  <pcarlini@unitus.it>

* include/bits/stl_algo.h (search_n): Improve the previous
fix as suggested by Martin.

From-SVN: r71913

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_algo.h

index 08ce582dc9cc5f3380248165b0911939af9ec77e..d6713f2d82cf10080e51c261e03290ab15e5a6cd 100644 (file)
@@ -1,3 +1,8 @@
+2003-09-29  Paolo Carlini  <pcarlini@unitus.it>
+
+       * include/bits/stl_algo.h (search_n): Improve the previous
+       fix as suggested by Martin.
+
 2003-09-29  Paolo Carlini  <pcarlini@unitus.it>
 
        PR libstdc++/12296
index 598eb0f01c9cafee095fc76df7ed2c81ef42d687..c92aa3c35438691bc820d7aae7d8946dacb76a3e 100644 (file)
@@ -609,7 +609,8 @@ namespace std
       else {
        __first = std::find(__first, __last, __val);
        while (__first != __last) {
-         typename iterator_traits<_ForwardIterator>::difference_type __n = __count - 1;
+         typename iterator_traits<_ForwardIterator>::difference_type __n = __count;
+         --__n;
          _ForwardIterator __i = __first;
          ++__i;
          while (__i != __last && __n != 0 && *__i == __val) {
@@ -661,7 +662,8 @@ namespace std
          ++__first;
        }
        while (__first != __last) {
-         typename iterator_traits<_ForwardIterator>::difference_type __n = __count - 1;
+         typename iterator_traits<_ForwardIterator>::difference_type __n = __count;
+         --__n;
          _ForwardIterator __i = __first;
          ++__i;
          while (__i != __last && __n != 0 && __binary_pred(*__i, __val)) {