Skip to content

Latest commit

 

History

History
37 lines (20 loc) · 1.07 KB

File metadata and controls

37 lines (20 loc) · 1.07 KB

 

 

 

 

 

 

Code snippet to replace negative values in a std::vector 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); }