fork(3) download
  1. #include <queue>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. bool cmp(int x, int y) { return (x > y); }
  6.  
  7. class A {
  8. public:
  9. private:
  10. priority_queue<int, vector<int>, decltype(cmp) > pq(cmp); // Error at pq(cmp) : function "cmp" is not a type name
  11. };
  12.  
  13.  
  14. int main() {
  15.  
  16. priority_queue<int, vector<int>, decltype(cmp) > pq(cmp); // no error here
  17. return 0;
  18. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:10:57: error: 'cmp' is not a type
     priority_queue<int, vector<int>, decltype(cmp) > pq(cmp); // Error at pq(cmp) : function "cmp" is not a type name
                                                         ^
In file included from /usr/include/c++/5/queue:64:0,
                 from prog.cpp:1:
/usr/include/c++/5/bits/stl_queue.h: In instantiation of 'class std::priority_queue<int, std::vector<int>, bool(int, int)>':
prog.cpp:16:60:   required from here
/usr/include/c++/5/bits/stl_queue.h:391:18: error: field 'std::priority_queue<int, std::vector<int>, bool(int, int)>::comp' invalidly declared function type
       _Compare   comp;
                  ^
stdout
Standard output is empty