...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Returns the distance between 2 iterators.
template< typename I, typename J > typename result_of::distance<I, J>::type distance(I const& i, J const& j);
Table 1.5. Parameters
Parameter |
Requirement |
Description |
---|---|---|
i, j |
Models of Forward Iterator into the same sequence |
The start and end points of the distance to be measured |
distance(i,j);
Return type: int
Semantics: Returns the distance between iterators i and j.
#include <boost/fusion/iterator/distance.hpp> #include <boost/fusion/include/distance.hpp>
typedef vector<int,int,int> vec; vec v(1,2,3); assert(distance(begin(v), next(next(begin(v)))) == 2);