Opened 10 years ago

Closed 9 years ago

#6888 closed Bugs (fixed)

range::unique does not forward predicate

Reported by: andy@… Owned by: Neil Groves
Milestone: To Be Determined Component: range
Version: Boost 1.49.0 Severity: Problem
Keywords: range unique Cc:

Description

At boost\range\algorithm\unique.hpp:92

/// \overload
template< class ForwardRange, class BinaryPredicate >
inline BOOST_DEDUCED_TYPENAME range_return<ForwardRange, return_begin_found>::type
unique( ForwardRange& rng, BinaryPredicate pred )
{
    BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
    return ::boost::range::unique<return_begin_found>(rng);
}

does not forward pred

Attachments (2)

unique_bug.cpp (415 bytes ) - added by andy@… 10 years ago.
Example of bug
unique_fix.diff (8.1 KB ) - added by andy@… 10 years ago.
Bug fix + test expansion to cover

Download all attachments as: .zip

Change History (7)

by andy@…, 10 years ago

Attachment: unique_bug.cpp added

Example of bug

by andy@…, 10 years ago

Attachment: unique_fix.diff added

Bug fix + test expansion to cover

comment:1 by andy@…, 10 years ago

I also changed the signature of the function accepting a const range&, range/algorithm/unique.hpp:96

inline BOOST_DEDUCED_TYPENAME range_return<const ForwardRange, return_begin_found>::type

That is in line with the other overloads, and I couldn't get the newer tests to work without that.

Additionally, in the unique.cpp tests, the predicate being used was incorrect - it was using std::less and std::greater for comparing equality. I changed them to be using std::equal_to

comment:2 by andy@…, 10 years ago

Component: Nonerange
Owner: set to Neil Groves

comment:3 by Neil Groves, 9 years ago

The proposed changes have been applied to the trunk. Thanks for helping. Please accept my apologies for failing to cover the full overload set.

in reply to:  3 comment:4 by andy@…, 9 years ago

No apology necessary! I love the Boost Range library, and am happy to have helped in this small way.

comment:5 by Neil Groves, 9 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.