diff options
author | Paolo Carlini <pcarlini@suse.de> | 2007-10-03 00:34:40 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2007-10-03 00:34:40 +0000 |
commit | f5ad31630d0c4912080793a30092202792ca7c4a (patch) | |
tree | 0328271ff471154d9aad238bb651d9d32f41ce10 /libstdc++-v3/include/debug/functions.h | |
parent | af2778d32e8d916747229999a1a359a3af764018 (diff) | |
download | gcc-f5ad31630d0c4912080793a30092202792ca7c4a.zip gcc-f5ad31630d0c4912080793a30092202792ca7c4a.tar.gz gcc-f5ad31630d0c4912080793a30092202792ca7c4a.tar.bz2 |
re PR libstdc++/33613 (compilation inconsistency upper_bound vs lower_bound with -D_GLIBCXX_DEBUG)
2007-10-03 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/33613
* include/debug/functions.h (__check_partitioned): Rename to...
(__check_partioned_lower): ... this.
(__check_partioned_upper): Add.
* include/debug/macros.h (__glibcxx_check_partitioned): Rename to...
(__glibcxx_check_partitioned_lower): ... this, adjust.
(__glibcxx_check_partitioned_upper): Add.
* include/debug/debug.h (__glibcxx_requires_partitioned): Rename to...
(__glibcxx_requires_partitioned_lower): ... this, adjust.
(__glibcxx_requires_partitioned_upper): Add.
* include/bits/stl_algo.h (lower_bound, upper_bound, equal_range,
binary search): Use the above.
* testsuite/25_algorithms/lower_bound/33613.cc: New.
* testsuite/25_algorithms/upper_bound/33613.cc: Likewise.
From-SVN: r128974
Diffstat (limited to 'libstdc++-v3/include/debug/functions.h')
-rw-r--r-- | libstdc++-v3/include/debug/functions.h | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/libstdc++-v3/include/debug/functions.h b/libstdc++-v3/include/debug/functions.h index ee7037f..15c2154 100644 --- a/libstdc++-v3/include/debug/functions.h +++ b/libstdc++-v3/include/debug/functions.h @@ -266,8 +266,8 @@ namespace __gnu_debug // Determine if a sequence is partitioned w.r.t. this element. template<typename _ForwardIterator, typename _Tp> inline bool - __check_partitioned(_ForwardIterator __first, _ForwardIterator __last, - const _Tp& __value) + __check_partitioned_lower(_ForwardIterator __first, + _ForwardIterator __last, const _Tp& __value) { while (__first != __last && *__first < __value) ++__first; @@ -276,15 +276,41 @@ namespace __gnu_debug return __first == __last; } + template<typename _ForwardIterator, typename _Tp> + inline bool + __check_partitioned_upper(_ForwardIterator __first, + _ForwardIterator __last, const _Tp& __value) + { + while (__first != __last && !(__value < *__first)) + ++__first; + while (__first != __last && __value < *__first) + ++__first; + return __first == __last; + } + // Determine if a sequence is partitioned w.r.t. this element. template<typename _ForwardIterator, typename _Tp, typename _Pred> inline bool - __check_partitioned(_ForwardIterator __first, _ForwardIterator __last, - const _Tp& __value, _Pred __pred) + __check_partitioned_lower(_ForwardIterator __first, + _ForwardIterator __last, const _Tp& __value, + _Pred __pred) + { + while (__first != __last && bool(__pred(*__first, __value))) + ++__first; + while (__first != __last && !bool(__pred(*__first, __value))) + ++__first; + return __first == __last; + } + + template<typename _ForwardIterator, typename _Tp, typename _Pred> + inline bool + __check_partitioned_upper(_ForwardIterator __first, + _ForwardIterator __last, const _Tp& __value, + _Pred __pred) { - while (__first != __last && __pred(*__first, __value)) + while (__first != __last && !bool(__pred(__value, *__first))) ++__first; - while (__first != __last && !__pred(*__first, __value)) + while (__first != __last && bool(__pred(__value, *__first))) ++__first; return __first == __last; } |