Go back to Richel Bilderbeek's homepage.

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

 

 

 

 

 

(C++) std::none_of

 

std::none_of is an STL algorithm since the C++11 standard to check if none of the elements from a container satisfy a certain predicate.

 

 

#include <algorithm>
#include <cassert>

int main()
{
  //Create a std::vector with only positive values
  const std::vector<int> v = { 0,1,2,3,4,5 };
  //Assume none of these has a value smaller than zero
  assert(std::none_of(v.begin(),v.end(),[](const int i){ return i < 0; } ));
}

 

 

 

 

 

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

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict