Back to Arangodb

count_if

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

3.12.9.12.8 KB
Original Source

| Prev Next | Back Along | Up Home | Full TOC | Front Page / Algorithms / Querying Algorithms / count_if |

count_if

Synopsis

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

Description

Returns the number of elements in Sequence that satisfy the predicate Pred.

#include <[boost/mpl/count\_if.hpp](../../../../boost/mpl/count_if.hpp)>

Parameters

ParameterRequirementDescription
SequenceForward SequenceA sequence to be examined.
PredUnary Lambda ExpressionA count condition.

Expression semantics

For any Forward Sequence s and unary Lambda Expression pred:

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

| Return type: |

Integral Constant.

| | Semantics: |

Equivalent to

typedef[lambda](./lambda.html)<pred>::type p;
typedef[fold](./fold.html)<
      s
    ,[long\_](./long.html)<0>
    ,[if\_](./if.html)<[apply\_wrap](./apply-wrap.html)1<p,[\_2](./placeholders.html)>,[next](./next.html)<[\_1](./placeholders.html)>,[\_1](./placeholders.html)>
    >::type n;

|

Complexity

Linear. Exactly size<s>::value applications of pred.

Example

typedef[vector](./vector.html)<int,char,long,short,char,long,double,long> types;[BOOST\_MPL\_ASSERT\_RELATION](./assert-relation.html)( ([count\_if](./count-if.html)< types, is_float<_> >::value), ==, 1 );[BOOST\_MPL\_ASSERT\_RELATION](./assert-relation.html)( ([count\_if](./count-if.html)< types, is_same<_,char> >::value), ==, 2 );[BOOST\_MPL\_ASSERT\_RELATION](./assert-relation.html)( ([count\_if](./count-if.html)< types, is_same<_,void> >::value), ==, 0 );

See also

Querying Algorithms, count, find, find_if, contains

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