Skip to content

Latest commit

 

History

History
56 lines (31 loc) · 1.17 KB

CppStdLess.md

File metadata and controls

56 lines (31 loc) · 1.17 KB

 

 

 

 

 

 

std::less is an STL predicate to perform operator< on two values.

 

 

 

 

 

Example

 

The code below shows how to replace values that are less than zero by a zero.

 


#include <vector> #include <algorithm #include <numeric>   //From http://www.richelbilderbeek.nl/CppReplaceNegativeByZero.htm void ReplaceNegativeByZero(std::vector<int>& v) {   std::replace_if(v.begin(),v.end(),     std::bind2nd(std::less<int>(),0),0); }