1. 程式人生 > >c++ 查詢容器中不滿足條件的元素,返回iterator(find_if_not)

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; }