fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template <class F>
  5. void funkcja (F &&comp) { }
  6.  
  7.  
  8.  
  9. template <class T, class F>
  10. class priority_queue {
  11. private:
  12. F &&comp;
  13.  
  14. public:
  15. priority_queue (F &&_comp) : comp(_comp) { }
  16. };
  17.  
  18. bool gr (int a, int b) { return true; }
  19.  
  20. int main() {
  21. priority_queue <int> a(gr);
  22. // funkcja(gr); // to dziala bez problemu
  23. return 0;
  24. }
Compilation error #stdin compilation error #stdout 0s 3092KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:21:21: error: wrong number of template arguments (1, should be 2)
  priority_queue <int> a(gr);
                     ^
prog.cpp:10:7: error: provided for ‘template<class T, class F> class priority_queue’
 class priority_queue {
       ^
prog.cpp:21:24: error: invalid type in declaration before ‘(’ token
  priority_queue <int> a(gr);
                        ^
prog.cpp:21:27: error: invalid conversion from ‘bool (*)(int, int)’ to ‘int’ [-fpermissive]
  priority_queue <int> a(gr);
                           ^
prog.cpp:21:23: warning: unused variable ‘a’ [-Wunused-variable]
  priority_queue <int> a(gr);
                       ^
stdout
Standard output is empty