[Home]contains

Synopsis

template<
      typename Sequence
    , typename T
    >
struct contains
{
    typedef unspecified type;
};

Description

Returns true_c if one or more elements in Sequence are identical to T, and false_c otherwise.

Definition

#include "boost/mpl/contains.hpp"

Parameters

 Parameter  Requirement  Description  
SequenceA model of Forward SequenceA sequence to be examined.
TA typeThe type to search for.

Expression semantics

 Expression  Expression type  Precondition  Semantics  Postcondition 
typedef contains<Sequence,T>::type c;A model of bool Integral ConstantEquivalent to typedef logical_not< is_same< find<Sequence,T>::type, end<Sequence>::type > >::type c;

Complexity

Linear. At most size<Sequence>::value comparisons for identity.

Example

typedef vector<char,int,unsigned,long,unsigned long> types;
typedef contains<types,bool>::type result;
BOOST_STATIC_ASSERT(!result::value);

See also

Algorithms, find, find_if, count, count_if


Table of Content | Reference
Last edited July 17, 2002 4:48 am