...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
template< typename Iterator , typename N > struct advance { typedef unspecified type; };
Returns an new iterator i
such as distance< Iterator,i >::type::value == N::value
.
#include "boost/mpl/advance.hpp"
Parameter | Requirement | Description |
---|---|---|
Iterator | A model of Input Iterator | |
N | A model of Integral Constant |
Expression | Expression type | Precondition | Semantics | Postcondition |
---|---|---|---|---|
typedef advance<Iterator,N>::type i; | A model of Input Iterator | Iterator and every iterator between Iterator and i (inclusive) is nonsingular; N::value must be nonnegative if Iterator is a model of Input Iterator or Forward Iterator | Equivalent to typedef Iterator::next i1; typedef i1::next i2; .. typedef in-1::next i; if N::value > 0 , and typedef Iterator::prior i1; typedef i1::prior i2; .. typedef in-1::prior i; otherwise; if N::value == 0 , the algorithm has no effect. | distance< Iterator,i >::type::value == N::value |
Amortized constant time if Iterator
is a model of Random Access Iterator, otherwise linear time.
typedef vector_c<int,0,1,2,3,4,5,6,7,8,9> numbers; typedef begin<numbers>::type first; typedef end<numbers>::type last; typedef advance_c<first,10>::type iter1; typedef advance_c<last,-10>::type iter2; BOOST_MPL_ASSERT_IS_SAME(iter1, last); BOOST_MPL_ASSERT_IS_SAME(iter2, first);
Iterators, Sequence, distance
, begin
, end