fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. template<typename C, typename F>
  6. typename C::const_iterator min_element(C const & c, F f)
  7. {
  8. return std::min_element(c.begin(), c.end(), f);
  9. }
  10.  
  11. int main() {
  12. std::vector<int> v{10,2,5,6,2,1,11,-1,23,54};
  13. std::cout << *min_element(v.begin(), v.end()) << std::endl;
  14. std::cout << *min_element(v, [](int a, int b) { return a < b;} ) << std::endl;
  15. return 0;
  16. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'typename C::const_iterator min_element(const C&, F)':
prog.cpp:8:11: error: 'min_element' is not a member of 'std'
prog.cpp: In function 'int main()':
prog.cpp:12:2: error: 'vector' is not a member of 'std'
prog.cpp:12:14: error: expected primary-expression before 'int'
prog.cpp:12:14: error: expected ';' before 'int'
prog.cpp:13:31: error: 'v' was not declared in this scope
stdout
Standard output is empty