1 .. Iterators/Iterator Metafunctions//advance |10
17 typedef |unspecified| type;
25 Moves ``Iterator`` by the distance ``N``. For |bidirectional| and
26 |random access| iterators, the distance may be negative.
34 #include <boost/mpl/advance.hpp>
40 +---------------+---------------------------+-----------------------------------+
41 | Parameter | Requirement | Description |
42 +===============+===========================+===================================+
43 | ``Iterator`` | |Forward Iterator| | An iterator to advance. |
44 +---------------+---------------------------+-----------------------------------+
45 | ``N`` | |Integral Constant| | A distance. |
46 +---------------+---------------------------+-----------------------------------+
52 |Tag Dispatched Metafunction|
58 For a |Forward Iterator| ``iter`` and arbitrary |Integral Constant| ``n``:
62 typedef advance<iter,n>::type j;
68 If ``Iterator`` is a |Forward Iterator|, ``n::value`` must be nonnegative.
76 typedef next<i0>::type i1;
78 typedef next<i\ *n-1*\ >::type j;
80 if ``n::value > 0``, and
85 typedef prior<i0>::type i1;
87 typedef prior<i\ *n-1*\ >::type j;
93 ``j`` is dereferenceable or past-the-end;
94 ``distance<iter,j>::value == n::value`` if ``n::value > 0``, and
95 ``distance<j,iter>::value == n::value`` otherwise.
101 Amortized constant time if ``iter`` is a model of
102 |Random Access Iterator|, otherwise linear time.
110 typedef range_c<int,0,10> numbers;
111 typedef begin<numbers>::type first;
112 typedef end<numbers>::type last;
114 typedef advance<first,int_<10> >::type i1;
115 typedef advance<last,int_<-10> >::type i2;
117 BOOST_MPL_ASSERT(( boost::is_same<i1,last> ));
118 BOOST_MPL_ASSERT(( boost::is_same<i2,first> ));
124 |Iterators|, |Tag Dispatched Metafunction|, |distance|, |next|
126 .. |bidirectional| replace:: `bidirectional`_
127 .. _bidirectional: `Bidirectional Iterator`_
128 .. |random access| replace:: `random access`_
129 .. _random access: `Random Access Iterator`_
132 .. copyright:: Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams
133 Distributed under the Boost Software License, Version 1.0. (See accompanying
134 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)