/ TYWZ /

记录详情

Compile Error

/in/foo.cc: In function 'int main()':
/in/foo.cc:25:42: error: no matching function for call to 'std::__cxx11::basic_string<char>::append(char&)'
  for(int i=r[0];i;i=r[i]) ans.append(s[i]);
                                          ^
In file included from /usr/include/c++/6/string:52:0,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/bits/ios_base.h:41,
                 from /usr/include/c++/6/ios:42,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from /in/foo.cc:1:
/usr/include/c++/6/bits/basic_string.h:1125:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>] <near match>
       append(const _CharT* __s)
       ^~~~~~
/usr/include/c++/6/bits/basic_string.h:1125:7: note:   conversion of argument 1 would be ill-formed:
/in/foo.cc:25:41: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
  for(int i=r[0];i;i=r[i]) ans.append(s[i]);
                                      ~~~^
In file included from /usr/include/c++/6/string:52:0,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/bits/ios_base.h:41,
                 from /usr/include/c++/6/ios:42,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from /in/foo.cc:1:
/usr/include/c++/6/bits/basic_string.h:1083:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
       append(const basic_string& __str)
       ^~~~~~
/usr/include/c++/6/bits/basic_string.h:1083:7: note:   no known conversion for argument 1 from 'char' to 'const std::__cxx11::basic_string<char>&'
/usr/include/c++/6/bits/basic_string.h:1100:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]
       append(const basic_string& __str, size_type __pos, size_type __n)
       ^~~~~~
/usr/include/c++/6/bits/basic_string.h:1100:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/6/bits/basic_string.h:1112:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(const _CharT*, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]
       append(const _CharT* __s, size_type __n)
       ^~~~~~
/usr/include/c++/6/bits/basic_string.h:1112:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/6/bits/basic_string.h:1142:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type = long unsigned int]
       append(size_type __n, _CharT __c)
       ^~~~~~
/usr/include/c++/6/bits/basic_string.h:1142:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/6/bits/basic_string.h:1152:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(std::initializer_list<_Tp>) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
       append(initializer_list<_CharT> __l)
       ^~~~~~
/usr/include/c++/6/bits/basic_string.h:1152:7: note:   no known conversion for argument 1 from 'char' to 'std::initializer_list<char>'
/usr/include/c++/6/bits/basic_string.h:1171:9: note: candidate: template<class _InputIterator, class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
         append(_InputIterator __first, _InputIterator __last)
         ^~~~~~
/usr/include/c++/6/bits/basic_string.h:1171:9: note:   template argument deduction/substitution failed:
/in/foo.cc:25:42: note:   candidate expects 2 arguments, 1 provided
  for(int i=r[0];i;i=r[i]) ans.append(s[i]);
                                          ^

信息

递交者
类型
递交
题目
2019.2.11 Problem A - string
语言
C++
递交时间
2019-02-25 22:12:27
评测时间
2019-02-25 22:12:27
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes