...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
template< typename Sequence , typename T > struct contains { typedef unspecified type; };
Returns true_
if one or more elements in Sequence
are identical to T
, and false_
otherwise.
#include "boost/mpl/contains.hpp"
Parameter | Requirement | Description |
---|---|---|
Sequence | A model of Forward Sequence | A sequence to be examined. |
T | A type | The type to search for. |
Expression | Expression type | Precondition | Semantics | Postcondition |
---|---|---|---|---|
typedef contains<Sequence,T>::type c; | A model of bool Integral Constant | Equivalent to typedef not_< is_same< find<Sequence,T>::type, end<Sequence>::type > >::type c ; |
Linear. At most size<Sequence>::value
comparisons for identity.
typedef vector<char,int,unsigned,long,unsigned long> types; typedef contains<types,bool>::type result; BOOST_STATIC_ASSERT(!result::value);
Algorithms, find
, find_if
, count
, count_if