Standard C++ Library Class Reference
 //
 // Now use this new predicate in a call to find_if
 //
 iterator it1 = find_if(v1.begin(),v1.end(),equal_to_3);
 //
 // Even better, construct the new predicate on the fly
 //
 iterator it2 = 
 find_if(v1.begin(),v1.end(),bind1st(equal_to<int>(),3)); 
 //
 // And now the same thing using bind2nd
 // Same result since == is commutative
 //
 iterator it3 = 
 find_if(v1.begin(),v1.end(),bind2nd(equal_to<int>(),3)); 
 //
 // it3 = v1.begin() + 2
 //
 // Output results
 //
 cout << *it1 << " " << *it2 << " " << *it3 << endl;
 return 0;
 }
Output : 3 3 3
Warnings
If your compiler does not support default template parameters then you need to always supply
the Allocator template argument. For instance you'll have to write:
vector<int,allocator>
instead of:
vector<int>
See Also
Function Objects










