fork(1) download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <limits>
  4. #include <vector>
  5.  
  6. int main() {
  7.  
  8. std::vector<bool> mask{0, 0, 1, 0, 1, 1, 0};
  9. std::vector<double> vec{7.1, 1.0, 3.2, 2.0, 1.8, 5.0, 0.0};
  10. std::vector<double> combined;
  11.  
  12. std::transform(vec.begin(), vec.end(), mask.begin(), std::back_inserter(combined),
  13. [](double v, bool mask) { return mask ? v : std::numeric_limits<double>::max(); });
  14.  
  15. auto it = std::min_element(combined.begin(), combined.end());
  16. std::cout << "min=" << *it << "\n";
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 5532KB
stdin
Standard input is empty
stdout
min=1.8