Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
Front Page / Iterators / Iterator Metafunctions / prior



      typename Iterator
struct prior
    typedef unspecified type;


Returns the previous iterator in the sequence. [Note: prior has a number of overloaded meanings, depending on the type of its argument. For instance, if X is an Integral Constant, prior<X> returns an decremented Integral Constant of the same type. The following specification is iterator-specific. Please refer to the corresponding concept's documentation for the details of the alternative semantics — end note].


#include <boost/mpl/next_prior.hpp>


Parameter Requirement Description
Iterator Bidirectional Iterator. An iterator to decrement.

Expression semantics

For any Bidirectional Iterators iter:

typedef prior<iter>::type j;
Return type:

Bidirectional Iterator.


iter is decrementable.


j is an iterator pointing to the previous element in the sequence. If iter is a user-defined iterator, the library-provided default implementation is equivalent to

typedef iter::prior j;


Amortized constant time.


typedef vector_c<int,1> v;
typedef begin<v>::type first;
typedef end<v>::type last;

BOOST_MPL_ASSERT(( is_same< prior<last>::type, first > ));

See also

Iterators, begin / end, next, deref