Opened 9 years ago
#8488 new Bugs
Code/doc mismatch in iterator_facade distance_to
Reported by: | 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
Self-contained test case demonstrating the problem