c++ 查找容器中不满足条件的元素,返回iterator(find_if_not)

 

#include <iostream>     // std::cout
#include <algorithm>    // std::find_if_not
#include <array>        // std::array
using namespace std;
int main () {
  array<int,5> foo = {1,2,3,4,5};

  array<int,5>::iterator it =find_if_not (foo.begin(), foo.end(), [](int i){return i%2;} );  //偶数就为假 
  cout << "The first even value is " << *it << '\n';

  return 0;
}

 

posted @ 2018-10-21 00:33  anobscureretreat  阅读(540)  评论(0编辑  收藏  举报