fork(2) download
  1. #include <iostream>
  2. #include <queue>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. struct myC {
  7. int i;
  8. myC(int x){
  9. this -> i = x;
  10. }
  11. // this is syntactically wrong
  12. // bool operator()(myC &a, myC &b) {
  13. // return a.i < b.i;
  14. // }
  15.  
  16. bool operator()(myC &b) {
  17. return this ->i < b.i;
  18. }
  19. };
  20.  
  21. int main() {
  22. // your code goes here
  23. priority_queue<myC, vector<myC>, myC> q;
  24. q.push(myC(10));
  25. q.pop();
  26. return 0;
  27. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:23:40: error: no matching function for call to ‘std::priority_queue<myC, std::vector<myC>, myC>::priority_queue()’
  priority_queue<myC, vector<myC>, myC> q;
                                        ^
In file included from /usr/include/c++/8/queue:64,
                 from prog.cpp:2:
/usr/include/c++/8/bits/stl_queue.h:564:2: note: candidate: ‘template<class _InputIterator> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, _Sequence&&)’
  priority_queue(_InputIterator __first, _InputIterator __last,
  ^~~~~~~~~~~~~~
/usr/include/c++/8/bits/stl_queue.h:564:2: note:   template argument deduction/substitution failed:
prog.cpp:23:40: note:   candidate expects 4 arguments, 0 provided
  priority_queue<myC, vector<myC>, myC> q;
                                        ^
In file included from /usr/include/c++/8/queue:64,
                 from prog.cpp:2:
/usr/include/c++/8/bits/stl_queue.h:553:2: note: candidate: ‘template<class _InputIterator> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Sequence&)’
  priority_queue(_InputIterator __first, _InputIterator __last,
  ^~~~~~~~~~~~~~
/usr/include/c++/8/bits/stl_queue.h:553:2: note:   template argument deduction/substitution failed:
prog.cpp:23:40: note:   candidate expects 4 arguments, 0 provided
  priority_queue<myC, vector<myC>, myC> q;
                                        ^
In file included from /usr/include/c++/8/queue:64,
                 from prog.cpp:2:
/usr/include/c++/8/bits/stl_queue.h:521:2: note: candidate: ‘template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(std::priority_queue<_Tp, _Sequence, _Compare>&&, const _Alloc&)’
  priority_queue(priority_queue&& __q, const _Alloc& __a)
  ^~~~~~~~~~~~~~
/usr/include/c++/8/bits/stl_queue.h:521:2: note:   template argument deduction/substitution failed:
prog.cpp:23:40: note:   candidate expects 2 arguments, 0 provided
  priority_queue<myC, vector<myC>, myC> q;
                                        ^
In file included from /usr/include/c++/8/queue:64,
                 from prog.cpp:2:
/usr/include/c++/8/bits/stl_queue.h:517:2: note: candidate: ‘template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const std::priority_queue<_Tp, _Sequence, _Compare>&, const _Alloc&)’
  priority_queue(const priority_queue& __q, const _Alloc& __a)
  ^~~~~~~~~~~~~~
/usr/include/c++/8/bits/stl_queue.h:517:2: note:   template argument deduction/substitution failed:
prog.cpp:23:40: note:   candidate expects 2 arguments, 0 provided
  priority_queue<myC, vector<myC>, myC> q;
                                        ^
In file included from /usr/include/c++/8/queue:64,
                 from prog.cpp:2:
/usr/include/c++/8/bits/stl_queue.h:513:2: note: candidate: ‘template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, _Sequence&&, const _Alloc&)’
  priority_queue(const _Compare& __x, _Sequence&& __c, const _Alloc& __a)
  ^~~~~~~~~~~~~~
/usr/include/c++/8/bits/stl_queue.h:513:2: note:   template argument deduction/substitution failed:
prog.cpp:23:40: note:   candidate expects 3 arguments, 0 provided
  priority_queue<myC, vector<myC>, myC> q;
                                        ^
In file included from /usr/include/c++/8/queue:64,
                 from prog.cpp:2:
/usr/include/c++/8/bits/stl_queue.h:508:2: note: candidate: ‘template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Sequence&, const _Alloc&)’
  priority_queue(const _Compare& __x, const _Sequence& __c,
  ^~~~~~~~~~~~~~
/usr/include/c++/8/bits/stl_queue.h:508:2: note:   template argument deduction/substitution failed:
prog.cpp:23:40: note:   candidate expects 3 arguments, 0 provided
  priority_queue<myC, vector<myC>, myC> q;
                                        ^
In file included from /usr/include/c++/8/queue:64,
                 from prog.cpp:2:
/usr/include/c++/8/bits/stl_queue.h:504:2: note: candidate: ‘template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Alloc&)’
  priority_queue(const _Compare& __x, const _Alloc& __a)
  ^~~~~~~~~~~~~~
/usr/include/c++/8/bits/stl_queue.h:504:2: note:   template argument deduction/substitution failed:
prog.cpp:23:40: note:   candidate expects 2 arguments, 0 provided
  priority_queue<myC, vector<myC>, myC> q;
                                        ^
In file included from /usr/include/c++/8/queue:64,
                 from prog.cpp:2:
/usr/include/c++/8/bits/stl_queue.h:500:2: note: candidate: ‘template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Alloc&)’
  priority_queue(const _Alloc& __a)
  ^~~~~~~~~~~~~~
/usr/include/c++/8/bits/stl_queue.h:500:2: note:   template argument deduction/substitution failed:
prog.cpp:23:40: note:   candidate expects 1 argument, 0 provided
  priority_queue<myC, vector<myC>, myC> q;
                                        ^
In file included from /usr/include/c++/8/queue:64,
                 from prog.cpp:2:
/usr/include/c++/8/bits/stl_queue.h:494:7: note: candidate: ‘std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, _Sequence&&) [with _Tp = myC; _Sequence = std::vector<myC>; _Compare = myC]’
       priority_queue(const _Compare& __x, _Sequence&& __s = _Sequence())
       ^~~~~~~~~~~~~~
/usr/include/c++/8/bits/stl_queue.h:494:7: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/8/bits/stl_queue.h:489:7: note: candidate: ‘std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Sequence&) [with _Tp = myC; _Sequence = std::vector<myC>; _Compare = myC]’
       priority_queue(const _Compare& __x, const _Sequence& __s)
       ^~~~~~~~~~~~~~
/usr/include/c++/8/bits/stl_queue.h:489:7: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/8/bits/stl_queue.h:485:2: note: candidate: ‘template<class _Seq, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue()’
  priority_queue()
  ^~~~~~~~~~~~~~
/usr/include/c++/8/bits/stl_queue.h:485:2: note:   template argument deduction/substitution failed:
/usr/include/c++/8/bits/stl_queue.h:482:43: error: no type named ‘type’ in ‘struct std::enable_if<false, void>’
       template<typename _Seq = _Sequence, typename _Requires = typename
                                           ^~~~~~~~
/usr/include/c++/8/bits/stl_queue.h:435:11: note: candidate: ‘std::priority_queue<myC, std::vector<myC>, myC>::priority_queue(const std::priority_queue<myC, std::vector<myC>, myC>&)’
     class priority_queue
           ^~~~~~~~~~~~~~
/usr/include/c++/8/bits/stl_queue.h:435:11: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/8/bits/stl_queue.h:435:11: note: candidate: ‘std::priority_queue<myC, std::vector<myC>, myC>::priority_queue(std::priority_queue<myC, std::vector<myC>, myC>&&)’
/usr/include/c++/8/bits/stl_queue.h:435:11: note:   candidate expects 1 argument, 0 provided
In file included from /usr/include/c++/8/bits/stl_algobase.h:71,
                 from /usr/include/c++/8/bits/char_traits.h:39,
                 from /usr/include/c++/8/ios:40,
                 from /usr/include/c++/8/ostream:38,
                 from /usr/include/c++/8/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/8/bits/predefined_ops.h: In instantiation of ‘bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<myC*, std::vector<myC> >; _Value = myC; _Compare = myC]’:
/usr/include/c++/8/bits/stl_heap.h:133:48:   required from ‘void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<myC*, std::vector<myC> >; _Distance = long int; _Tp = myC; _Compare = __gnu_cxx::__ops::_Iter_comp_val<myC>]’
/usr/include/c++/8/bits/stl_heap.h:207:23:   required from ‘void std::push_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<myC*, std::vector<myC> >; _Compare = myC]’
/usr/include/c++/8/bits/stl_queue.h:618:16:   required from ‘void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = myC; _Sequence = std::vector<myC>; _Compare = myC; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = myC]’
prog.cpp:24:16:   required from here
/usr/include/c++/8/bits/predefined_ops.h:177:11: error: no match for call to ‘(myC) (myC&, myC&)’
  { return bool(_M_comp(*__it, __val)); }
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.cpp:16:7: note: candidate: ‘bool myC::operator()(myC&)’
  bool operator()(myC &b) {
       ^~~~~~~~
prog.cpp:16:7: note:   candidate expects 1 argument, 2 provided
In file included from /usr/include/c++/8/bits/stl_algobase.h:71,
                 from /usr/include/c++/8/bits/char_traits.h:39,
                 from /usr/include/c++/8/ios:40,
                 from /usr/include/c++/8/ostream:38,
                 from /usr/include/c++/8/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/8/bits/predefined_ops.h: In instantiation of ‘constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<myC*, std::vector<myC> >; _Iterator2 = __gnu_cxx::__normal_iterator<myC*, std::vector<myC> >; _Compare = myC]’:
/usr/include/c++/8/bits/stl_heap.h:222:14:   required from ‘void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<myC*, std::vector<myC> >; _Distance = long int; _Tp = myC; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<myC>]’
/usr/include/c++/8/bits/stl_heap.h:253:25:   required from ‘void std::__pop_heap(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<myC*, std::vector<myC> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<myC>]’
/usr/include/c++/8/bits/stl_heap.h:320:19:   required from ‘void std::pop_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<myC*, std::vector<myC> >; _Compare = myC]’
/usr/include/c++/8/bits/stl_queue.h:645:15:   required from ‘void std::priority_queue<_Tp, _Sequence, _Compare>::pop() [with _Tp = myC; _Sequence = std::vector<myC>; _Compare = myC]’
prog.cpp:25:8:   required from here
/usr/include/c++/8/bits/predefined_ops.h:143:18: error: no match for call to ‘(myC) (myC&, myC&)’
         { return bool(_M_comp(*__it1, *__it2)); }
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.cpp:16:7: note: candidate: ‘bool myC::operator()(myC&)’
  bool operator()(myC &b) {
       ^~~~~~~~
prog.cpp:16:7: note:   candidate expects 1 argument, 2 provided
stdout
Standard output is empty