# Man Page find.3

```
Standard C++ Library
Copyright 1998, Rogue Wave Software, Inc.

```

## NAME

```     find

- Finds an occurrence of value in a sequence.

```

## SYNOPSIS

```     #include <algorithm>
template <class InputIterator, class T>
InputIterator find(InputIterator first,
InputIterator last,
const T& value);

```

## DESCRIPTION

```     The find algorithm lets you search for the first  occurrence
of  a particular value in a sequence. find_returns the first
iterator i in the range [first, last) for which the  follow-
ing condition holds:

*i == value.

If find does not find a match  for  value,  it  returns  the
iterator last.

Type T must be EqualityComparable.

```

## COMPLEXITY

```     find performs at most last-first comparisons.

```

## EXAMPLE

```     //
// find.cpp
//
#include <vector>
#include <algorithm>
#include <functional>
#include <iostream>

using namespace std;

int main()
{
typedef vector<int>::iterator iterator;
int d1[10] = {0,1,2,2,3,4,2,2,6,7};

// Set up a vector
vector<int> v1(d1,d1 + 10);

// Try find
iterator it1 = find(v1.begin(),v1.end(),3);
// it1 = v1.begin() + 4;

// Try find_if
iterator it2 =
find_if(v1.begin(),v1.end(),bind1st(equal_to<int>(),3));
// it2 = v1.begin() + 4

// it3 = v1.begin() +2

iterator it4 =
// v4 = v1.begin() + 2

// Output results
cout << *it1 << " " << *it2 << " " << *it3 << " "
<< *it4 << endl;

return 0;
}

Program Output

3 3 2 2

```

## WARNINGS

```     If your compiler does not support default  template  parame-
ters,  then you always need to supply the Allocator template
argument. For instance, you have to write:

vector<int,allocator<int> >

vector<int>

If your compiler does not support namespaces,  then  you  do
not need the using declaration for std.

```

```     adjacent_find, find_first_of, find_if

```