find声明:
示例:
- template<class InputIterator, class Type>
- InputIterator find(
- InputIterator _First,
- InputIterator _Last,
- const Type& _Val
- );
- void test_find()
- {
- std::list <int> L;
- std::list <int>::iterator Iter;
- std::list <int>::iterator result;
- L.push_back(40);
- L.push_back(20);
- L.push_back(10);
- L.push_back(30);
- L.push_back(10);
- std::copy(L.cbegin(), L.cend(), std::ostream_iterator<int>(std::cout, " "));
- std::cout << std::endl;
- result = std::find(L.begin(), L.end(), 10);
- if (result == L.end())
- std::cout << "There is no 10 in list L.";
- else {
- std::cout << "There is a 10 in list L";
- if (++result != L.end())
- std::cout << " and it is followed by a " << *result << ".";
- }
- std::cout << std::endl;
- }