Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) std::find_if_not

 

std::find_if_not is a C++11 algorithm to find an element in a container that does not satisfy a certain predicate.

 

 

#include <algorithm>
#include <cassert>
#include <vector>

int main()
{
  const std::vector<int> v = { 1,3,5,7,9,10,11,13,15,17,19 };

  assert(
    *std::find_if_not(
      v.begin(),v.end(),
        [v](const int i)
        {
          return i%2; //An even number
        }
      )
    == 10);
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml