Opened 9 years ago

#8488 new Bugs

Code/doc mismatch in iterator_facade distance_to

Reported by: gredner@… Owned by: jeffrey.hellrung
Milestone: To Be Determined Component: iterator
Version: Boost 1.52.0 Severity: Problem
Keywords: Cc: jeffrey.hellrung@…

Description

When creating a random access facade, one must implement the distance_to member function in order for std::distance to work. However, it looks like the arguments passed to this method are reversed from what the documentation states.

Specifically, the docs [1] say (paraphrased): a.distance_to(b) is equivalent to distance(a, b).

However, when I call std::distance(a, b), I find that b.distance_to(a) is invoked in the facade - the mirror image of what the docs say!

A test case demonstrating the problem is attached.

[1] http://www.boost.org/doc/libs/1_53_0/libs/iterator/doc/iterator_facade.html#iterator-facade-requirements

Attachments (1)

main.cpp (1.2 KB ) - added by gredner@… 9 years ago.
Self-contained test case demonstrating the problem

Download all attachments as: .zip

Change History (1)

by gredner@…, 9 years ago

Attachment: main.cpp added

Self-contained test case demonstrating the problem

Note: See TracTickets for help on using tickets.