fork(1) download
  1. #include <iostream>
  2. #include <algorithm>
  3. using namepsace std;
  4.  
  5. template <int n>
  6. int min(int args[n])
  7. {
  8. return min_element(args, args+n);
  9. }
  10.  
  11. int main()
  12. {
  13. int n;
  14. cin >> n;
  15.  
  16. int arr[n];
  17. for(int i=0; i<n; i++)
  18. cin >> arr[i];
  19.  
  20. cout << min(arr);
  21. cout << min({2, 1, 3});
  22. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:3:7: error: expected nested-name-specifier before ‘namepsace’
prog.cpp:3:7: error: ‘namepsace’ has not been declared
prog.cpp:3:17: error: expected ‘;’ before ‘std’
prog.cpp:3:17: error: ‘std’ does not name a type
prog.cpp: In function ‘int min(int*)’:
prog.cpp:8:36: error: there are no arguments to ‘min_element’ that depend on a template parameter, so a declaration of ‘min_element’ must be available [-fpermissive]
prog.cpp:8:36: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
prog.cpp: In function ‘int main()’:
prog.cpp:14:5: error: ‘cin’ was not declared in this scope
prog.cpp:14:5: note: suggested alternative:
In file included from prog.cpp:1:0:
/usr/include/c++/4.7/iostream:61:18: note:   ‘std::cin’
prog.cpp:20:5: error: ‘cout’ was not declared in this scope
prog.cpp:20:5: note: suggested alternative:
In file included from prog.cpp:1:0:
/usr/include/c++/4.7/iostream:62:18: note:   ‘std::cout’
prog.cpp:20:20: error: no matching function for call to ‘min(int [(((sizetype)(((ssizetype)n) + -1)) + 1)])’
prog.cpp:20:20: note: candidate is:
prog.cpp:6:5: note: template<int n> int min(int*)
prog.cpp:6:5: note:   template argument deduction/substitution failed:
prog.cpp:20:20: note:   couldn't deduce template parameter ‘n’
prog.cpp:21:16: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
prog.cpp:21:26: error: no matching function for call to ‘min(<brace-enclosed initializer list>)’
prog.cpp:21:26: note: candidate is:
prog.cpp:6:5: note: template<int n> int min(int*)
prog.cpp:6:5: note:   template argument deduction/substitution failed:
prog.cpp:21:26: note:   cannot convert ‘{2, 1, 3}’ (type ‘<brace-enclosed initializer list>’) to type ‘int*’
stdout
Standard output is empty