?
std::find_first_of
- C++98
- C++11
-
| equality (1) |
template
ForwardIterator1 find_first_of (InputIterator first1, InputIterator last1,
ForwardIterator first2, ForwardIterator last2);
|
| predicate (2) |
template
ForwardIterator1 find_first_of (InputIterator first1, InputIterator last1,
ForwardIterator first2, ForwardIterator last2,
BinaryPredicate pred);
|
Find element from set in range Returns an iterator to the first element in the range [first1,last1) that matches any of the elements in [first2,last2). If no such element is found, the function returns last1. 返回一个迭代器,指向范围[first1,last1)中第一个匹配到[first2,last1)中的任一(并不要求全部匹配)元素。如果没有匹配的,则返回last1. 例子: ?
#include
#include
#include
#include
using namespace std; void findfirstof() { vector
v1{1,2,3,4,5,6,3,4,9,8}; int arr[]={4,8}; array
ai{77,88}; cout<
例子:
?
可以看到,只要匹配到一个元素符号要求,就返回。 The elements in
[first1,last1) are sequentially compared to each of the values in
[first2,last2) using
operator== (or
pred, in version
(2)), until a pair matches.
[first1,last1)中的每一个元素依次和[first2,last2)中的每一个元素匹配,直到一个匹配出现。
The behavior of this function template is equivalent to:
(仔细看下面的代码就能看出来)
|