Hi Andrzej, Andrzej Krzemienski wrote:
IMHO, Boost.Iterator should provide BoostIteratorTraversalConcepts-aware `boost::advance` and `boost::distance` to avoid the inefficiencies.
Not just inefficiencies. Using `prev()` may simply cause UB. See here: https://akrzemi1.wordpress.com/2017/01/02/not-detecting-bugs/
Yes, and ditto for `std::advance` with negative numbers. Your blog is helpful; thank you for writing C++ blog!
However, neither of them are implemented. (Boost.Range has `boost::distance` for ranges, but it just calls `std::distance`.)
I'm attaching files that implement `boost::advance` and `boost::distance`. Would these functions be useful additions?
They are necessary for Boost to be consistent. But I think this means coupling two libraries.
Do you mean coupling of Boost.Iterator and Boost.Range? I think that would be fine, since Boost.Range already couples with Boost.Iterator. Boost.Range's `boost::distance` should call Boost.Iterator's `boost::distance`. Regards, Michel