Opened 14 years ago

Closed 14 years ago

#1993 closed Bugs (invalid)

Incorrect iterator_category computation in some iterator classes in Boost.Iterator

Reported by: Wijnand Suijlen <wijnandsuijlen@…> Owned by: Dave Abrahams
Milestone: Boost 1.36.0 Component: iterator
Version: Boost 1.35.0 Severity: Problem
Keywords: Cc:

Description

In contrary of the documentation of Boost.Iterator transform_iterator and zip_iterator are not random access iterators, when their bases are. I discovered this, when profiling an application. The culprit was std::lower_bound on a transform_iterator< Function, std::deque<int> >: Its complexity was not O( log n ) but more something like O( n2 ). The attached program shows with help of the Boost concept check, that the iterator_category in transform_iterator and zip_iterator isn't computed correctly.

Attachments (1)

example.cpp (1.3 KB ) - added by Wijnand Suijlen <wijnandsuijlen@…> 14 years ago.
Smallest program suffering from bug

Download all attachments as: .zip

Change History (2)

by Wijnand Suijlen <wijnandsuijlen@…>, 14 years ago

Attachment: example.cpp added

Smallest program suffering from bug

comment:1 by Dave Abrahams, 14 years ago

Resolution: invalid
Status: newclosed

The categories are correctly computed. An iterator cannot be called a standard forward iterator unless its operator* returns value_type&, and that is not possible with a zip iterator or with a transform iterator whose function returns by value. Please see http://www.boost.org/doc/libs/1_35_0/libs/iterator/doc/new-iter-concepts.html#motivation

If you think you can get away with it, you can always specialize std::iterator_traits<It> to lie about the iterator's iterator_category.

Note: See TracTickets for help on using tickets.