C++ STL find_first_of 用法
一:功能
给定两个序列 A 和 B,在A序列中查找是否存在B序列中的元素,如找到则返回第一匹配到的元素。
二:用法
#include <iostream>
#include <vector>
#include <algorithm>int main() {std::vector<int> haystack = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };std::vector<int> needles = { 7, 5, 3 };auto it = std::find_first_of(haystack.begin(), haystack.end(), needles.begin(), needles.end());std::cout << "*it == " << *it << "\n";
}