Back to Arangodb

advance

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

3.12.9.13.3 KB
Original Source

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

advance

Synopsis

template<
      typename Iterator
    , typename N
    >
struct[advance](./advance.html){
    typedef_unspecified_type;
};

Description

Moves Iterator by the distance N. For bidirectional and random access iterators, the distance may be negative.

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

Parameters

ParameterRequirementDescription
IteratorForward IteratorAn iterator to advance.
NIntegral ConstantA distance.

Model Of

Tag Dispatched Metafunction

Expression semantics

For a Forward Iterator iter and arbitrary Integral Constant n:

typedef[advance](./advance.html)<iter,n>::type j;

| Return type: |

Forward Iterator.

| | Precondition: |

If Iterator is a Forward Iterator, n::value must be nonnegative.

| | Semantics: |

Equivalent to:

typedef iter i0;
typedef[next](./next.html)<i0>::type i1;_..._typedef[next](./next.html)<i_n-1_>::type j;

if n::value > 0, and

typedef iter i0;
typedef[prior](./prior.html)<i0>::type i1;_..._typedef[prior](./prior.html)<i_n-1_>::type j;

otherwise.

| | Postcondition: |

j is dereferenceable or past-the-end; distance<iter,j>::value == n::value if n::value > 0, and distance<j,iter>::value == n::value otherwise.

|

Complexity

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

Example

typedef[range\_c](./range-c.html)<int,0,10> numbers;
typedef[begin](./begin.html)<numbers>::type first;
typedef[end](./end.html)<numbers>::type last;

typedef[advance](./advance.html)<first,[int\_](./int.html)<10> >::type i1;
typedef[advance](./advance.html)<last,[int\_](./int.html)<-10> >::type i2;[BOOST\_MPL\_ASSERT](./assert.html)(( boost::is_same<i1,last> ));[BOOST\_MPL\_ASSERT](./assert.html)(( boost::is_same<i2,first> ));

See also

Iterators, Tag Dispatched Metafunction, distance, next

| 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) |