...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Front Page / Iterators / Iterator Metafunctions / advance |
Moves Iterator by the distance N. For bidirectional and random access iterators, the distance may be negative.
#include <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::type j;
Return type: | |
---|---|
Precondition: | If Iterator is a Forward Iterator, n::value must be nonnegative. |
Semantics: | Equivalent to: typedef iter i0; typedef next if n::value > 0, and typedef iter i0; typedef prior otherwise. |
Postcondition: | j is dereferenceable or past-the-end;
distance |
Amortized constant time if iter is a model of Random Access Iterator, otherwise linear time.
typedef range_cnumbers; typedef begin ::type first; typedef end ::type last; typedef advance int_<10> >::type i1; typedef advance int_<-10> >::type i2; BOOST_MPL_ASSERT(( boost::is_same )); BOOST_MPL_ASSERT(( boost::is_same ));