Skip to content

Latest commit

 

History

History
44 lines (25 loc) · 1.33 KB

CppStdAny_of.md

File metadata and controls

44 lines (25 loc) · 1.33 KB

 

 

 

 

 

 

std::any_of is an STL algorithm since the C++11 standard to check if there is an element in a container that satisfies 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 any of these has the value of three   assert(std::any_of(v.begin(),v.end(),[](const int i){ return i == 3; } )); }