Back to Arangodb

copy_if

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

3.12.9.13.7 KB
Original Source

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

copy_if

Synopsis

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

Description

Returns a filtered copy of the original sequence containing the elements 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/copy\_if.hpp](../../../../boost/mpl/copy_if.hpp)>

Model of

Reversible Algorithm

Parameters

ParameterRequirementDescription
SequenceForward SequenceA sequence to copy.
PredUnary Lambda ExpressionA copying condition.
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, and an Inserter in:

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

| Return type: |

A type.

| | Semantics: |

Equivalent to

typedef[lambda](./lambda.html)<pred>::type p;
typedef[lambda](./lambda.html)<in::operation>::type op;

typedef[fold](./fold.html)<
      s
    , in::state
    ,[eval\_if](./eval-if.html)<[apply\_wrap](./apply-wrap.html)1<p,[\_2](./placeholders.html)>
        ,[apply\_wrap](./apply-wrap.html)2<op,[\_1](./placeholders.html),[\_2](./placeholders.html)>
        ,[identity](./identity.html)<[\_1](./placeholders.html)>
        >
    >::type r;

|

Complexity

Linear. Exactly size<s>::value applications of pred, and at most size<s>::value applications of in::operation.

Example

typedef[copy\_if](./copy-if.html)<[range\_c](./range-c.html)<int,0,10>
    ,[less](./less.html)<[\_1](./placeholders.html),[int\_](./int.html)<5> >
    ,[back\_inserter](./back-inserter.html)<[vector](./vector.html)<> >
    >::type result;[BOOST\_MPL\_ASSERT\_RELATION](./assert-relation.html)([size](./size.html)<result>::value, ==, 5 );[BOOST\_MPL\_ASSERT](./assert.html)(([equal](./equal.html)<result,[range\_c](./range-c.html)<int,0,5> > ));

See also

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

| 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) |