3rdParty/boost/1.78.0/libs/mpl/doc/refmanual/advance.html
| Prev Next | Back Along | Up Home | Full TOC | Front Page / Iterators / Iterator Metafunctions / advance |
template<
typename Iterator
, typename N
>
struct[advance](./advance.html){
typedef_unspecified_type;
};
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)>
| Parameter | Requirement | Description |
|---|---|---|
| Iterator | Forward Iterator | An iterator to advance. |
| N | Integral Constant | A distance. |
For a Forward Iterator iter and arbitrary Integral Constant n:
typedef[advance](./advance.html)<iter,n>::type j;
| Return type: |
| | 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.
|
Amortized constant time if iter is a model of Random Access Iterator, otherwise linear time.
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> ));
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) |