Translations of this page?:

find_first_of

Syntax:

    #include <algorithm>
    forward_iterator find_first_of( forward_iterator start, forward_iterator end, forward_iterator2 find_start, forward_iterator2 find_end );
    forward_iterator find_first_of( forward_iterator start, forward_iterator end, forward_iterator2 find_start, forward_iterator2 find_end, BinPred bp );

The find_first_of() function searches for the first occurence of any element between find_start and find_end. The data that are searched are those between start and end.

If any element between find_start and find_end is found, an iterator pointing to that element is returned. Otherwise, an iterator pointing to end is returned.

For example, the following code searches for a 9, 4, or 7 in an array of integers:

   int nums[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
   int* result;
   int start = 0;
   int end = 10;
 
   int targets[] = { 9, 4, 7 };
   result = find_first_of( nums + start, nums + end, targets + 0, targets + 3 );
   if( *result == nums[end] ) {
     cout << "Did not find any of { 9, 4, 7 }" << endl;
   } else {
     cout << "Found a matching target: " << *result << endl;
   }

Related Topics: adjacent_find, find, find_end, find_if, strpbrk

 
• • • IndexRecent changesRSScc