Standard C++ Library Class Reference

Click on the banner to return to the Class Reference home page.
©Copyright 1996 Rogue Wave Software
distance
Iterator Operation
Summary
Computes the distance between two iterators
Contents
Synopsis
Description
Example
Warning
See Also
Synopsis
#include <iterator>
template <class InputIterator, class Distance>
void distance (InputIterator first,
InputIterator last,
Distance& n);
Description
The distance template function computes the distance between two iterators and stores that
value in n. The last iterator must be reachable from the first iterator.
distance increments n by the number of times it takes to get from first to last. distance must be
a three argument function that stores the result into a reference instead of returning the result,
because the distance type cannot be deduced from built-in iterator types such as int*.