Back to Arangodb

reverse_replace_if

3rdParty/boost/1.78.0/libs/mpl/doc/refmanual/reverse-replace-if.html

3.12.9.13.7 KB
Original Source

| Prev Next | Back Along | Up Home | Full TOC | Front Page / Algorithms / Transformation Algorithms / reverse_replace_if |

reverse_replace_if

Synopsis

template<
      typename Sequence
    , typename Pred
    , typename In =_unspecified_>
struct[reverse\_replace\_if](./reverse-replace-if.html){
    typedef_unspecified_type;
};

Description

Returns a reversed copy of the original sequence where every type that satisfies the predicate Pred has been replaced with NewType.

[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/replace\_if.hpp](../../../../boost/mpl/replace_if.hpp)>

Model of

Reversible Algorithm

Parameters

ParameterRequirementDescription
SequenceForward SequenceAn original sequence.
PredUnary Lambda ExpressionA replacement condition.
NewTypeAny typeA type to replace with.
InInserterAn 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, an unary Lambda Expression pred, an Inserter in, and arbitrary type x:

typedef[reverse\_replace\_if](./reverse-replace-if.html)<s,pred,x,in>::type r;

| Return type: |

A type.

| | Semantics: |

Equivalent to

typedef[lambda](./lambda.html)<pred>::type p;
typedef[reverse\_transform](./reverse-transform.html)< s,[if\_](./if.html)< apply_wrap1<p,[\_1](./placeholders.html)>,x,[\_1](./placeholders.html)>, in >::type r;

|

Complexity

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

Example

typedef[vector\_c](./vector-c.html)<int,1,4,5,2,7,5,3,5> numbers;
typedef[vector\_c](./vector-c.html)<int,1,4,0,2,0,0,3,0> expected;
typedef[reverse\_replace\_if](./reverse-replace-if.html)<
      numbers
    ,[greater](./greater.html)< _,[int\_](./int.html)<4> >
    ,[int\_](./int.html)<0>
    ,[front\_inserter](./front-inserter.html)<[vector](./vector.html)<> >
    >::type result;[BOOST\_MPL\_ASSERT](./assert.html)(([equal](./equal.html)< result,expected,[equal\_to](./equal-to.html)<_,_> > ));

See also

Transformation Algorithms, Reversible Algorithm, replace_if, reverse_replace, remove_if, transform

| Prev Next | Back Along | Up Home | Full TOC |

Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |