Bug ustl::remove_copy_if
fhirmann opened this issue · 2 comments
fhirmann commented
I found a bug in the implementation of ustl::remove_copy_if. This also affects the ustl::remove_if which is often used for erasing elements in containers.
The implementation should be:
Remove_copy_if copies elements from the range [first, last) to a range beginning at result, except that elements for which pred is true are not copied.
There is a missing negation at pred (*first)
so the function should be:
inline OutputIterator remove_copy_if (InputIterator first, InputIterator last, OutputIterator result, Predicate pred)
{
for (; first != last; ++first)
if (!pred (*first))
*result++ = *first;
return result;
}
dgruss commented
That's right.
This issue is already fixed in the upstream ustl:
https://github.com/msharov/ustl/issues/66
I will update the ustl integrated in SWEB sooner or later to pull
these bugfixes in.
fhirmann commented
Thanks for your fast response.