Commit dded9d2c by Paolo Carlini Committed by Paolo Carlini

re PR libstdc++/31556 (find_if uses operator! instead of conversion to bool)

2007-04-13  Paolo Carlini  <pcarlini@suse.de>

	PR libstdc++/31556
	* include/bits/stl_algobase.h (equal(_InputIterator1, _InputIterator1,
	_InputIterator2, _BinaryPredicate), mismatch(_InputIterator1,
	_InputIterator1, _InputIterator2, _BinaryPredicate)): Convert
	predicate return to bool.
	* include/bits/stl_algo.h (__find_if(_InputIterator, _InputIterator,
	_Predicate, input_iterator_tag), search(_ForwardIterator1,
	_ForwardIterator1, _ForwardIterator2, _ForwardIterator2,
	_BinaryPredicate), __search_n(_ForwardIterator, _ForwardIterator,
	_Integer, const _Tp&, _BinaryPredicate, std::forward_iterator_tag),
	__search_n(_RandomAccessIter, _RandomAccessIter, _Integer, const _Tp&,
	_BinaryPredicate, std::random_access_iterator_tag),
	search_n(_ForwardIterator, _ForwardIterator, _Integer, const _Tp&,
	_BinaryPredicate), remove_copy_if(_InputIterator, _InputIterator,
	_OutputIterator, _Predicate), __unique_copy(_ForwardIterator,
	_ForwardIterator, _OutputIterator, _BinaryPredicate,
	forward_iterator_tag, output_iterator_tag),
	__unique_copy(_InputIterator, _InputIterator, _OutputIterator,
	_BinaryPredicate, input_iterator_tag, output_iterator_tag),
	__unique_copy(_InputIterator, _InputIterator, _OutputIterator,
	_BinaryPredicate, input_iterator_tag, output_iterator_tag),
	__unique_copy(_InputIterator, _InputIterator, _ForwardIterator,
	_BinaryPredicate, input_iterator_tag, forward_iterator_tag),
	unique(_ForwardIterator, _ForwardIterator, _BinaryPredicate),
	__partition(_BidirectionalIterator, _BidirectionalIterator, _Predicate,
	bidirectional_iterator_tag), binary_search(_ForwardIterator,
	_ForwardIterator, const _Tp&, _Compare),
	next_permutation(_BidirectionalIterator, _BidirectionalIterator,
	_Compare), prev_permutation(_BidirectionalIterator,
	_BidirectionalIterator, _Compare)): Likewise.

From-SVN: r123800
parent 601589db
2007-04-13 Paolo Carlini <pcarlini@suse.de> 2007-04-13 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/31556
* include/bits/stl_algobase.h (equal(_InputIterator1, _InputIterator1,
_InputIterator2, _BinaryPredicate), mismatch(_InputIterator1,
_InputIterator1, _InputIterator2, _BinaryPredicate)): Convert
predicate return to bool.
* include/bits/stl_algo.h (__find_if(_InputIterator, _InputIterator,
_Predicate, input_iterator_tag), search(_ForwardIterator1,
_ForwardIterator1, _ForwardIterator2, _ForwardIterator2,
_BinaryPredicate), __search_n(_ForwardIterator, _ForwardIterator,
_Integer, const _Tp&, _BinaryPredicate, std::forward_iterator_tag),
__search_n(_RandomAccessIter, _RandomAccessIter, _Integer, const _Tp&,
_BinaryPredicate, std::random_access_iterator_tag),
search_n(_ForwardIterator, _ForwardIterator, _Integer, const _Tp&,
_BinaryPredicate), remove_copy_if(_InputIterator, _InputIterator,
_OutputIterator, _Predicate), __unique_copy(_ForwardIterator,
_ForwardIterator, _OutputIterator, _BinaryPredicate,
forward_iterator_tag, output_iterator_tag),
__unique_copy(_InputIterator, _InputIterator, _OutputIterator,
_BinaryPredicate, input_iterator_tag, output_iterator_tag),
__unique_copy(_InputIterator, _InputIterator, _OutputIterator,
_BinaryPredicate, input_iterator_tag, output_iterator_tag),
__unique_copy(_InputIterator, _InputIterator, _ForwardIterator,
_BinaryPredicate, input_iterator_tag, forward_iterator_tag),
unique(_ForwardIterator, _ForwardIterator, _BinaryPredicate),
__partition(_BidirectionalIterator, _BidirectionalIterator, _Predicate,
bidirectional_iterator_tag), binary_search(_ForwardIterator,
_ForwardIterator, const _Tp&, _Compare),
next_permutation(_BidirectionalIterator, _BidirectionalIterator,
_Compare), prev_permutation(_BidirectionalIterator,
_BidirectionalIterator, _Compare)): Likewise.
2007-04-13 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/31554 PR libstdc++/31554
* include/bits/stl_algo.h (stable_partition): Convert __buf.size() * include/bits/stl_algo.h (stable_partition): Convert __buf.size()
to _DistanceType. to _DistanceType.
......
...@@ -186,7 +186,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -186,7 +186,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__find_if(_InputIterator __first, _InputIterator __last, __find_if(_InputIterator __first, _InputIterator __last,
_Predicate __pred, input_iterator_tag) _Predicate __pred, input_iterator_tag)
{ {
while (__first != __last && !__pred(*__first)) while (__first != __last && !bool(__pred(*__first)))
++__first; ++__first;
return __first; return __first;
} }
...@@ -568,7 +568,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -568,7 +568,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
++__tmp; ++__tmp;
if (__tmp == __last2) if (__tmp == __last2)
{ {
while (__first1 != __last1 && !__predicate(*__first1, *__first2)) while (__first1 != __last1
&& !bool(__predicate(*__first1, *__first2)))
++__first1; ++__first1;
return __first1; return __first1;
} }
...@@ -586,7 +587,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -586,7 +587,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
break; break;
++__first1; ++__first1;
} }
while (__first1 != __last1 && !__predicate(*__first1, *__first2)) while (__first1 != __last1 &&
!bool(__predicate(*__first1, *__first2)))
++__first1; ++__first1;
if (__first1 == __last1) if (__first1 == __last1)
return __last1; return __last1;
...@@ -741,7 +743,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -741,7 +743,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_Integer __count, const _Tp& __val, _Integer __count, const _Tp& __val,
_BinaryPredicate __binary_pred, std::forward_iterator_tag) _BinaryPredicate __binary_pred, std::forward_iterator_tag)
{ {
while (__first != __last && !__binary_pred(*__first, __val)) while (__first != __last && !bool(__binary_pred(*__first, __val)))
++__first; ++__first;
while (__first != __last) while (__first != __last)
...@@ -750,7 +752,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -750,7 +752,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__n = __count; __n = __count;
_ForwardIterator __i = __first; _ForwardIterator __i = __first;
++__i; ++__i;
while (__i != __last && __n != 1 && __binary_pred(*__i, __val)) while (__i != __last && __n != 1 && bool(__binary_pred(*__i, __val)))
{ {
++__i; ++__i;
--__n; --__n;
...@@ -760,7 +762,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -760,7 +762,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
if (__i == __last) if (__i == __last)
return __last; return __last;
__first = ++__i; __first = ++__i;
while (__first != __last && !__binary_pred(*__first, __val)) while (__first != __last
&& !bool(__binary_pred(*__first, __val)))
++__first; ++__first;
} }
return __last; return __last;
...@@ -799,7 +802,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -799,7 +802,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ {
// __lookAhead here is always pointing to the last element of next // __lookAhead here is always pointing to the last element of next
// possible match. // possible match.
while (!__binary_pred(*__lookAhead, __val)) // the skip loop... while (!bool(__binary_pred(*__lookAhead, __val))) // the skip loop...
{ {
if (__tailSize < __pattSize) if (__tailSize < __pattSize)
return __last; // Failure return __last; // Failure
...@@ -852,7 +855,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -852,7 +855,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
return __first; return __first;
if (__count == 1) if (__count == 1)
{ {
while (__first != __last && !__binary_pred(*__first, __val)) while (__first != __last && !bool(__binary_pred(*__first, __val)))
++__first; ++__first;
return __first; return __first;
} }
...@@ -1180,7 +1183,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1180,7 +1183,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__glibcxx_requires_valid_range(__first, __last); __glibcxx_requires_valid_range(__first, __last);
for ( ; __first != __last; ++__first) for ( ; __first != __last; ++__first)
if (!__pred(*__first)) if (!bool(__pred(*__first)))
{ {
*__result = *__first; *__result = *__first;
++__result; ++__result;
...@@ -1352,7 +1355,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1352,7 +1355,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_ForwardIterator __next = __first; _ForwardIterator __next = __first;
*__result = *__first; *__result = *__first;
while (++__next != __last) while (++__next != __last)
if (!__binary_pred(*__first, *__next)) if (!bool(__binary_pred(*__first, *__next)))
{ {
__first = __next; __first = __next;
*++__result = *__first; *++__result = *__first;
...@@ -1383,7 +1386,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1383,7 +1386,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
typename iterator_traits<_InputIterator>::value_type __value = *__first; typename iterator_traits<_InputIterator>::value_type __value = *__first;
*__result = __value; *__result = __value;
while (++__first != __last) while (++__first != __last)
if (!__binary_pred(__value, *__first)) if (!bool(__binary_pred(__value, *__first)))
{ {
__value = *__first; __value = *__first;
*++__result = __value; *++__result = __value;
...@@ -1413,7 +1416,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1413,7 +1416,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
*__result = *__first; *__result = *__first;
while (++__first != __last) while (++__first != __last)
if (!__binary_pred(*__result, *__first)) if (!bool(__binary_pred(*__result, *__first)))
*++__result = *__first; *++__result = *__first;
return ++__result; return ++__result;
} }
...@@ -1574,7 +1577,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1574,7 +1577,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_ForwardIterator __dest = __first; _ForwardIterator __dest = __first;
++__first; ++__first;
while (++__first != __last) while (++__first != __last)
if (!__binary_pred(*__dest, *__first)) if (!bool(__binary_pred(*__dest, *__first)))
*++__dest = *__first; *++__dest = *__first;
return ++__dest; return ++__dest;
} }
...@@ -2025,7 +2028,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -2025,7 +2028,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
while (true) while (true)
if (__first == __last) if (__first == __last)
return __first; return __first;
else if (!__pred(*__last)) else if (!bool(__pred(*__last)))
--__last; --__last;
else else
break; break;
...@@ -4227,7 +4230,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -4227,7 +4230,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__glibcxx_requires_partitioned_pred(__first, __last, __val, __comp); __glibcxx_requires_partitioned_pred(__first, __last, __val, __comp);
_ForwardIterator __i = std::lower_bound(__first, __last, __val, __comp); _ForwardIterator __i = std::lower_bound(__first, __last, __val, __comp);
return __i != __last && !__comp(__val, *__i); return __i != __last && !bool(__comp(__val, *__i));
} }
// Set algorithms: includes, set_union, set_intersection, set_difference, // Set algorithms: includes, set_union, set_intersection, set_difference,
...@@ -4875,7 +4878,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -4875,7 +4878,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
if (__first == __last) return __first; if (__first == __last) return __first;
_ForwardIterator __result = __first; _ForwardIterator __result = __first;
while (++__first != __last) while (++__first != __last)
if (__comp(*__result, *__first)) __result = __first; if (__comp(*__result, *__first))
__result = __first;
return __result; return __result;
} }
...@@ -5032,7 +5036,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -5032,7 +5036,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
if (__comp(*__i, *__ii)) if (__comp(*__i, *__ii))
{ {
_BidirectionalIterator __j = __last; _BidirectionalIterator __j = __last;
while (!__comp(*__i, *--__j)) while (!bool(__comp(*__i, *--__j)))
{} {}
std::iter_swap(__i, __j); std::iter_swap(__i, __j);
std::reverse(__ii, __last); std::reverse(__ii, __last);
...@@ -5143,7 +5147,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -5143,7 +5147,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
if (__comp(*__ii, *__i)) if (__comp(*__ii, *__i))
{ {
_BidirectionalIterator __j = __last; _BidirectionalIterator __j = __last;
while (!__comp(*--__j, *__i)) while (!bool(__comp(*--__j, *__i)))
{} {}
std::iter_swap(__i, __j); std::iter_swap(__i, __j);
std::reverse(__ii, __last); std::reverse(__ii, __last);
......
...@@ -848,7 +848,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -848,7 +848,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_requires_valid_range(__first1, __last1); __glibcxx_requires_valid_range(__first1, __last1);
while (__first1 != __last1 && __binary_pred(*__first1, *__first2)) while (__first1 != __last1 && bool(__binary_pred(*__first1, *__first2)))
{ {
++__first1; ++__first1;
++__first2; ++__first2;
...@@ -912,7 +912,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -912,7 +912,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__glibcxx_requires_valid_range(__first1, __last1); __glibcxx_requires_valid_range(__first1, __last1);
for (; __first1 != __last1; ++__first1, ++__first2) for (; __first1 != __last1; ++__first1, ++__first2)
if (!__binary_pred(*__first1, *__first2)) if (!bool(__binary_pred(*__first1, *__first2)))
return false; return false;
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment