记录详情

Compile Error

foo.cc: In function 'std::ostream& operator<<(std::ostream&, ComplexArray&)':
foo.cc:73:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Complex>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |   for (int i = 0; i < c.Cs.size(); i++)
      |                   ~~^~~~~~~~~~~~~
foo.cc: In member function 'void ComplexArray::mysort()':
foo.cc:79:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Complex>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |   for (int i = 0; i < Cs.size() - 1; i++)
      |                   ~~^~~~~~~~~~~~~~~
foo.cc:81:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Complex>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |    for (int j = 0; j < Cs.size() - 1 - i; j++)
      |                    ~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/string:41,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from foo.cc:1:
/usr/include/c++/9/ext/new_allocator.h: In instantiation of 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = Complex; _Args = {const Complex&}; _Tp = Complex]':
/usr/include/c++/9/bits/alloc_traits.h:483:4:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = Complex; _Args = {const Complex&}; _Tp = Complex; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<Complex>]'
/usr/include/c++/9/bits/stl_vector.h:1189:30:   required from 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = Complex; _Alloc = std::allocator<Complex>; std::vector<_Tp, _Alloc>::value_type = Complex]'
foo.cc:67:18:   required from here
/usr/include/c++/9/ext/new_allocator.h:146:4: error: binding reference of type 'Complex&' to 'const Complex' discards qualifiers
  146 |  { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foo.cc:11:19: note:   initializing argument 1 of 'Complex::Complex(Complex&)'
   11 |  Complex(Complex& c) :real(c.real), image(c.image) { }
      |          ~~~~~~~~~^
In file included from /usr/include/c++/9/vector:66,
                 from foo.cc:2:
/usr/include/c++/9/bits/stl_uninitialized.h: In instantiation of '_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = std::move_iterator<Complex*>; _ForwardIterator = Complex*]':
/usr/include/c++/9/bits/stl_uninitialized.h:307:37:   required from '_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with _InputIterator = std::move_iterator<Complex*>; _ForwardIterator = Complex*; _Tp = Complex]'
/usr/include/c++/9/bits/stl_uninitialized.h:329:2:   required from '_ForwardIterator std::__uninitialized_move_if_noexcept_a(_InputIterator, _InputIterator, _ForwardIterator, _Allocator&) [with _InputIterator = Complex*; _ForwardIterator = Complex*; _Allocator = std::allocator<Complex>]'
/usr/include/c++/9/bits/vector.tcc:474:3:   required from 'void std::vector<_Tp, _Alloc>::_M_realloc_insert(std::vector<_Tp, _Alloc>::iterator, _Args&& ...) [with _Args = {const Complex&}; _Tp = Complex; _Alloc = std::allocator<Complex>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<Complex*, std::vector<Complex> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = Complex*]'
/usr/include/c++/9/bits/stl_vector.h:1195:4:   required from 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = Complex; _Alloc = std::allocator<Complex>; std::vector<_Tp, _Alloc>::value_type = Complex]'
foo.cc:67:18:   required from here
/usr/include/c++/9/bits/stl_uninitialized.h:127:72: error: static assertion failed: result type must be constructible from value type of input range
  127 |       static_assert(is_constructible<_ValueType2, decltype(*__first)>::value,
      |                                                                        ^~~~~
[Hydro](https://hydro.ac)提供评测服务

信息

递交者
类型
自测
题目
P1013 OO2-3 复数数组类的冒泡排序
语言
C++
递交时间
2022-04-25 10:27:27
评测时间
2022-04-25 10:27:27
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes