Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#9403 closed Bugs (fixed)

[ranges] typo in equal_impl causes O(N) impl to be selected instead of O(1) impl

Reported by: Eric Niebler Owned by: Neil Groves
Milestone: To Be Determined Component: range
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

The following overload of equal_impl will never be selected because it doesn't take the extra two tag parameters that the others do:

    template< class RandomAccessTraversalReadableIterator1,
                class RandomAccessTraversalReadableIterator2,
                class BinaryPredicate >
    inline bool equal_impl( RandomAccessTraversalReadableIterator1 first1,
                            RandomAccessTraversalReadableIterator1 last1,
                            RandomAccessTraversalReadableIterator2 first2,
                            RandomAccessTraversalReadableIterator2 last2,
                            BinaryPredicate                        pred )
    {
        return ((last1 - first1) == (last2 - first2))
            && std::equal(first1, last1, first2, pred);
    }

Change History (3)

comment:1 by Neil Groves, 9 years ago

Status: newassigned

comment:2 by Neil Groves, 9 years ago

Resolution: fixed
Status: assignedclosed

Argh, what a school boy error - sorry.

comment:3 by Eric Niebler, 9 years ago

Ha! These errors are hard to spot. The code compiles and yields the correct results, after all. Don't sweat it.

Note: See TracTickets for help on using tickets.