Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is an old version of boost. Click here for the latest version's documentation home page.

[Home]distance

Synopsis

template<
      typename First
    , typename Last
    >
struct distance
{
    typedef unspecified type;
};

Description

Finds the distance between First and Last, that is, an Integral Constant D such as advance< First,D >::type is identical to Last.

Definition

#include "boost/mpl/distance.hpp"

Parameters

 Parameter  Requirement  Description  
First, LastA model of Input Iterator

Expression semantics

 Expression  Expression type  Precondition  Semantics  Postcondition 
typedef distance<First,Last>::type d;A model of Integral Constant[First, Last) is a valid rangeis_same< advance< First,d >::type, Last >::value

Complexity

Amortized constant time if Iterator is a model of Random Access Iterator, otherwise linear time.

Example

typedef range_c<int,0,10>::type range;
BOOST_STATIC_ASSERT((distance< begin<range>::type,end<range>::type >::type::value == 10));

See also

Iterators, Sequence, advance, begin, end


Table of Contents
Last edited July 17, 2002 6:47 am