From 6821a40b747dc32328e3ceab54ff47eee39694d8 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Mon, 29 Sep 2003 21:43:04 +0200 Subject: [PATCH] stl_algo.h (search_n): Improve the previous fix as suggested by Martin. 2003-09-29 Paolo Carlini * include/bits/stl_algo.h (search_n): Improve the previous fix as suggested by Martin. From-SVN: r71913 --- libstdc++-v3/ChangeLog | 5 +++++ libstdc++-v3/include/bits/stl_algo.h | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 08ce582dc9c..d6713f2d82c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2003-09-29 Paolo Carlini + + * include/bits/stl_algo.h (search_n): Improve the previous + fix as suggested by Martin. + 2003-09-29 Paolo Carlini PR libstdc++/12296 diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index 598eb0f01c9..c92aa3c3543 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -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)) { -- 2.30.2