Boost C++ Libraries

...one 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 for the latest Boost documentation.

[Home]contains

Synopsis

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

Description

Returns true_ if one or more elements in Sequence are identical to T, and false_ 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 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 Contents
Last edited March 10, 2003 5:33 am