Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Standard C++ Library Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

distance()

Module:  Standard C++ Library   Library:  Iterators


Function

Local Index

No Entries

Summary

A function that computes the distance between two iterators

Synopsis

#include <iterator>

namespace std {
  template <class ForwardIterator>
  iterator_traits<ForwardIterator>::difference_type
  distance(ForwardIterator start,
           ForwardIterator finish);

  template <class ForwardIterator, class Distance>
  void distance(ForwardIterator start,
                ForwardIterator finish,
                Distance& n);
}

Description

The distance() function template computes the distance between two iterators. The first version returns that value, while the second version increments n by that value. The last iterator must be reachable from the first iterator.

Note that the second version of this function is obsolete. It is included for backward compatibility and to accommodate compilers that do not support partial specialization. The first version of the function is not available with compilers that do not support partial specialization, since it depends on iterator_traits, which itself depends on that particular language feature.

Example

Warnings

If your compiler does not support partial specialization, you can't use the version of distance() that returns the distance. Instead, you must use the version that increments a reference parameter.

See Also

Sequences, Random Access Iterators

Standards Conformance

ISO/IEC 14882:1998 -- International Standard for Information Systems -- Programming Language C++, Section 24.3.4



Previous fileTop of DocumentContentsIndex pageNext file

Copyright (c) 1994-2006 Rogue Wave Software, a Quovadx Division.
Licensed under the Apache License, Version 2.0.
Contact Rogue Wave about documentation or support issues. You can also seek help from other developers through the Apache stdcxx community (see below).

For more information on the Rogue Wave Standard C++ Library under open source, see Section 1.2 of the user's guide.