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]find

Synopsis

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

Description

Finds the first occurrence of type T in a Sequence.

Definition

#include "boost/mpl/find.hpp"

Parameters

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

Expression semantics

 Expression  Expression type  Precondition  Semantics  Postcondition 
typedef find<Sequence,T>::type i;A model of Forward IteratorEquivalent to typedef find_if<Sequence, is_same<_,T> >::type i;

Complexity

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

Example

typedef vector<char,int,unsigned,long,unsigned long> types;
typedef find<types,unsigned>::type iter;
BOOST_STATIC_ASSERT(iter::pos::value == 2);

See also

Algorithms, find_if, contains, count, count_if


Table of Contents
Last edited September 15, 2002 7:24 pm