Compile Error

/in/foo.cc: In function 'int main()':
/in/foo.cc:7:19: error: no matching function for call to 'find(std::string&, char)'
    7 |         int k=find(s,'!');
      |               ~~~~^~~~~~~
In file included from /usr/include/c++/12/bits/locale_facets.h:48,
                 from /usr/include/c++/12/bits/basic_ios.h:37,
                 from /usr/include/c++/12/ios:44,
                 from /usr/include/c++/12/istream:38,
                 from /usr/include/c++/12/sstream:38,
                 from /usr/include/c++/12/complex:45,
                 from /usr/include/c++/12/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/12/bits/stdc++.h:54,
                 from /in/foo.cc:1:
/usr/include/c++/12/bits/streambuf_iterator.h:434:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  434 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/12/bits/streambuf_iterator.h:434:5: note:   template argument deduction/substitution failed:
/in/foo.cc:7:19: note:   'std::__cxx11::basic_string<char>' is not derived from 'std::istreambuf_iterator<_CharT>'
    7 |         int k=find(s,'!');
      |               ~~~~^~~~~~~
In file included from /usr/include/c++/12/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/12/bits/stdc++.h:65:
/usr/include/c++/12/bits/stl_algo.h:3843:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)'
 3843 |     find(_InputIterator __first, _InputIterator __last,
      |     ^~~~
/usr/include/c++/12/bits/stl_algo.h:3843:5: note:   template argument deduction/substitution failed:
/in/foo.cc:7:19: note:   deduced conflicting types for parameter '_IIter' ('std::__cxx11::basic_string<char>' and 'char')
    7 |         int k=find(s,'!');
      |               ~~~~^~~~~~~

信息

递交者
类型
自测
题目
P2531 字符串逆序
语言
C++
递交时间
2026-11-28 15:00:14
评测时间
2026-11-28 15:00:14
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes