Back to Arangodb

distance

3rdParty/boost/1.78.0/libs/mpl/doc/refmanual/distance.html

3.12.9.12.9 KB
Original Source

| Prev Next | Back Along | Up Home | Full TOC | Front Page / Iterators / Iterator Metafunctions / distance |

distance

Synopsis

template<
      typename First
    , typename Last
    >
struct[distance](./distance.html){
    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.

#include <[boost/mpl/distance.hpp](../../../../boost/mpl/distance.hpp)>

Parameters

ParameterRequirementDescription
First, LastForward IteratorIterators to compute a distance between.

Model Of

Tag Dispatched Metafunction

Expression semantics

For any Forward Iterators first and last:

typedef[distance](./distance.html)<first,last>::type n;

| Return type: |

Integral Constant.

| | Precondition: |

[first, last) is a valid range.

| | Semantics: |

Equivalent to

typedef[iter\_fold](./iter-fold.html)<[iterator\_range](./iterator-range.html)<first,last>
    ,[long\_](./long.html)<0>
    ,[next](./next.html)<[\_1](./placeholders.html)>
    >::type n;

| | Postcondition: |

is_same< advance<first,n>::type, last >::value == true.

|

Complexity

Amortized constant time if first and last are Random Access Iterators, otherwise linear time.

Example

typedef[range\_c](./range-c.html)<int,0,10>::type range;
typedef[begin](./begin.html)<range>::type first;
typedef[end](./end.html)<range>::type last;[BOOST\_MPL\_ASSERT\_RELATION](./assert-relation.html)( ([distance](./distance.html)<first,last>::value), ==, 10);

See also

Iterators, Tag Dispatched Metafunction, advance, next, prior

| Prev Next | Back Along | Up Home | Full TOC |

Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |