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 / Algorithms / Transformation Algorithms / reverse_remove_if



      typename Sequence
    , typename Pred
    , typename In = unspecified
struct reverse_remove_if
    typedef unspecified type;


Returns a new sequence that contains all the elements from [begin<Sequence>::type, end<Sequence>::type) range in reverse order except those that satisfy the predicate Pred.

[Note: This wording applies to a no-inserter version(s) of the algorithm. See the Expression semantics subsection for a precise specification of the algorithm's details in all cases — end note]


#include <boost/mpl/remove_if.hpp>

Model of

Reversible Algorithm


Parameter Requirement Description
Sequence Forward Sequence An original sequence.
Pred Unary Lambda Expression A removal condition.
In Inserter An inserter.

Expression semantics

The semantics of an expression are defined only where they differ from, or are not defined in Reversible Algorithm.

For any Forward Sequence s, and an Inserter in, and an unary Lambda Expression pred:

typedef reverse_remove_if<s,pred,in>::type r;
Return type:

A type.


Equivalent to

typedef lambda<pred>::type p;
typedef lambda<in::operation>::type op;

typedef reverse_fold<
    , in::state
    , eval_if<
        , identity<_1>
        , apply_wrap2<op,_1,_2>
    >::type r;


Linear. Performs exactly size<s>::value applications of pred, and at most size<s>::value insertions.


typedef vector_c<int,1,4,5,2,7,5,3,5>::type numbers;
typedef reverse_remove_if< numbers, greater<_,int_<4> > >::type result;

BOOST_MPL_ASSERT(( equal< result,vector_c<int,3,2,4,1>,equal_to<_,_> > ));

See also

Transformation Algorithms, Reversible Algorithm, remove_if, reverse_remove, reverse_copy_if, replace_if