The STL find algorithm looks for the first element in a list with value = value. It is written as follows:
template <class InputIterator, class T>The following code fragment builds a list of future computations and executes find() over this list to find the first element in the list with a zero value.InputIterator find(InputIterator first,
InputIterator last,
const T& value)
{
while (first != last && *first != value)
{
++first;
}
return first;
}
int foo(const int i);Here find computes only to the point where it finds an element with a value = value. The remaining futures need not even be computed or resolved.typedef Future<int> future_type;
typedef list<future_type> list_type;
list_type xlist;
for(int i = 0; i < N; i++)
xlist.push_back(future_type(foo, i)); // add to list
list_type::iterator pos
= find(xlist.begin(), xlist.end(), 0);