Boost logo

Boost :

Subject: Re: [boost] [iterator][range] BoostIteratorTraversalConcepts-aware boost::advance/distance
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2017-06-28 20:14:07

2017-06-28 22:03 GMT+02:00 Michel Morin via Boost <boost_at_[hidden]>:

> Hi,
> The Boost iterator traversal concepts have not been adopted by the C++
> Standard.
> Because of this, some of RandomAccessTraversalIterators (Boost's concepts)
> are
> treated as InputIterators (Standard's concepts) by the stdlib.
> 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:

> 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.


Boost list run by bdawes at, gregod at, cpdaniel at, john at