distance
template<
typename First
, typename Last
>
struct distance
{
typedef unspecified type;
};
Finds the distance between First and Last, that is, an Integral Constant D such as advance< First,D >::type is identical to Last.
#include "boost/mpl/distance.hpp"
| Parameter | Requirement | Description |
|---|---|---|
First, Last | A model of Input Iterator |
| Expression | Expression type | Precondition | Semantics | Postcondition |
|---|---|---|---|---|
typedef distance<First,Last>::type d; | A model of Integral Constant | [First, Last) is a valid range | is_same< advance< First,d >::type, Last >::value |
Amortized constant time if Iterator is a model of Random Access Iterator, otherwise linear time.
typedef range_c<int,0,10>::type range; BOOST_STATIC_ASSERT((distance< begin<range>::type,end<range>::type >::type::value == 10));
Iterators, Sequence, advance, begin, end