source:
downloads/boost_1_33_1/libs/mpl/doc/src/refmanual/distance.rst
@
12
| Last change on this file since 12 was 12, checked in by landauf, 18 years ago | |
|---|---|
| File size: 2.1 KB | |
distance
Synopsis
template<
typename First
, typename Last
>
struct distance
{
typedef |unspecified| type;
};
Description
Returns the distance between First and Last iterators, that is, an |Integral Constant| n such that advance<First,n>::type is identical to Last.
Header
#include <boost/mpl/distance.hpp>
Parameters
| Parameter | Requirement | Description |
|---|---|---|
| First, Last | |Forward Iterator| | Iterators to compute a distance between. |
Model Of
Expression semantics
For any |Forward Iterator|s first and last:
typedef distance<first,last>::type n;
| Return type: | |
|---|---|
| Precondition: | [first, last) is a valid range. |
| Semantics: | Equivalent to
typedef iter_fold<
iterator_range<first,last>
, long_<0>
, next<_1>
>::type n;
|
| Postcondition: | is_same< advance<first,n>::type, last >::value == true. |
Complexity
Amortized constant time if first and last are |Random Access Iterator|s, otherwise linear time.
Example
typedef range_c<int,0,10>::type range; typedef begin<range>::type first; typedef end<range>::type last; BOOST_MPL_ASSERT_RELATION( (distance<first,last>::value), ==, 10);
See also
|Iterators|, |Tag Dispatched Metafunction|, |advance|, |next|, |prior|
Note: See TracBrowser
for help on using the repository browser.










