fork download
  1. #include <boost/iterator/transform_iterator.hpp>
  2. #include <boost/bind.hpp>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <iostream>
  6. struct S
  7. {
  8. int i;
  9. char *s;
  10. float f;
  11. };
  12.  
  13. int main()
  14. {
  15. S a[] = {{10, NULL, 2.1},
  16. {11, NULL, 0.1},
  17. {12, NULL, 1.1}};
  18. std::vector<S> v(a, a+3);
  19. std::cout << *std::min_element(
  20. boost::make_transform_iterator(v.begin(), boost::bind(&S::f, _1)),
  21. boost::make_transform_iterator(v.end(), boost::bind(&S::f, _1))
  22. ) << '\n';
  23. }
  24.  
Success #stdin #stdout 0s 2856KB
stdin
Standard input is empty
stdout
0.1