Compile Error

foo.cc: In member function ‘bool Node::operator<(Node)’:
foo.cc:8:45: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
    8 |                 return num<b.num||num==b.num&&id<b.id;
      |                                   ~~~~~~~~~~^~~~~~~~~
In file included from /nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algobase.h:71,
                 from /nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/algorithm:60,
                 from stdc++.h:51:
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/predefined_ops.h: In instantiation of ‘bool __gnu_cxx::__ops::_Val_less_iter::operator()(_Value&, _Iterator) const [with _Value = const Node; _Iterator = Node*]’:
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:1993:14:   required from ‘_ForwardIterator std::__upper_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = Node*; _Tp = Node; _Compare = __gnu_cxx::__ops::_Val_less_iter]’
 1993 |           if (__comp(__val, __middle))
      |               ~~~~~~^~~~~~~~~~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:2469:26:   required from ‘void std::__merge_without_buffer(_BidirectionalIterator, _BidirectionalIterator, _BidirectionalIterator, _Distance, _Distance, _Compare) [with _BidirectionalIterator = Node*; _Distance = long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
 2469 |             = std::__upper_bound(__first, __middle, *__second_cut,
      |               ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2470 |                                  __gnu_cxx::__ops::__val_comp_iter(__comp));
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:2754:34:   required from ‘void std::__inplace_stable_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = Node*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
 2754 |       std::__merge_without_buffer(__first, __middle, __last,
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
 2755 |                                   __middle - __first,
      |                                   ~~~~~~~~~~~~~~~~~~~
 2756 |                                   __last - __middle,
      |                                   ~~~~~~~~~~~~~~~~~~
 2757 |                                   __comp);
      |                                   ~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:4956:28:   required from ‘void std::__stable_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = Node*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
 4956 |         std::__inplace_stable_sort(__first, __last, __comp);
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:4994:36:   required from ‘void std::stable_sort(_RAIter, _RAIter) [with _RAIter = Node*]’
 4994 |       _GLIBCXX_STD_A::__stable_sort(__first, __last,
      |                                    ^
foo.cc:48:13:   required from here
   48 |         stable_sort(a+1,a+1+n);
      |         ~~~~~~~~~~~^~~~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/predefined_ops.h:98:22: error: no match for ‘operator<’ (operand types are ‘const Node’ and ‘Node’)
   98 |       { return __val < *__it; }
      |                ~~~~~~^~~~~~~
foo.cc:6:14: note: candidate: ‘bool Node::operator<(Node)’ (near match)
    6 |         bool operator<(Node b)
      |              ^~~~~~~~
foo.cc:6:14: note:   passing ‘const Node*’ as ‘this’ argument discards qualifiers
In file included from /nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algobase.h:67:
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_iterator.h:1241:5: note: candidate: ‘template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)’
 1241 |     operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
      |     ^~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_iterator.h:1241:5: note:   template argument deduction/substitution failed:
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/predefined_ops.h:98:22: note:   ‘const Node’ is not derived from ‘const __gnu_cxx::__normal_iterator<_IteratorL, _Container>’
   98 |       { return __val < *__it; }
      |                ~~~~~~^~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_iterator.h:1249:5: note: candidate: ‘template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)’
 1249 |     operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
      |     ^~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_iterator.h:1249:5: note:   template argument deduction/substitution failed:
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/predefined_ops.h:98:22: note:   ‘const Node’ is not derived from ‘const __gnu_cxx::__normal_iterator<_Iterator, _Container>’
   98 |       { return __val < *__it; }
      |                ~~~~~~^~~~~~~

信息

递交者
类型
递交
题目
P2433 插入排序
语言
C++
递交时间
2025-07-19 13:48:35
评测时间
2025-07-19 13:48:35
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes