diff options
-rw-r--r-- | libstdc++-v3/ChangeLog | 5 | ||||
-rw-r--r-- | 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 08ce582..d6713f2 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,10 @@ 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 * include/bits/istream.tcc (peek): Set eofbit if sgetc returns eof. diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index 598eb0f..c92aa3c 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)) { |