Re: s.erase(remove(s.begin(),s.end(),'a'),s.end()

作者: lturtsamuel (港都都教授)   2024-01-08 15:01:34
: → Wardyal: .replace("a", "") :) 01/08 14:37
./Playground/file0.cpp: In function 'void haha(std::string_view)':
./Playground/file0.cpp:23:14: error: no matching function for call to
'std::__cxx11::basic_string<char>::replace(const char [2], const char [1])'
23 | s.replace("a", "");
| ~~~~~~~~~^~~~~~~~~
In file included from ../Playground/++/12.2.0/string:53,
from ../Playground/++../Playground/:40,
from ../Playground/++../Playground/:41,
from ../Playground/++/12.2.0/ios:42,
from ../Playground/++/12.2.0/ostream:38,
from ../Playground/++/12.2.0/iostream:39,
from ./Playground/file0.cpp:2:
../Playground/++../Playground/:2331:9: note: candidate: 'template<class
_InputIterator, class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(const_iterator,
const_iterator, _InputIterator, _InputIterator) [with
<template-parameter-2-2> = _InputIterator; _CharT = char; _Traits =
std::char_traits<char>; _Alloc = std::allocator<char>]'
2331 | replace(const_iterator __i1, const_iterator __i2,
| ^~~~~~~
../Playground/++../Playground/:2331:9: note: template argument
deduction/substitution failed:
./Playground/file0.cpp:23:14: note: candidate expects 4 arguments, 2
provided
23 | s.replace("a", "");
| ~~~~~~~~~^~~~~~~~~
../Playground/++../Playground/:2440:9: note: candidate: 'template<class _Tp>
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp,
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&>
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type,
size_type, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>;
_Alloc = std::allocator<char>]'
2440 | replace(size_type __pos, size_type __n, const _Tp& __svt)
| ^~~~~~~
../Playground/++../Playground/:2440:9: note: template argument
deduction/substitution failed:
./Playground/file0.cpp:23:14: note: candidate expects 3 arguments, 2
provided
23 | s.replace("a", "");
| ~~~~~~~~~^~~~~~~~~
../Playground/++../Playground/:2458:9: note: candidate: 'template<class _Tp>
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp,
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&>
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type,
size_type, const _Tp&, size_type, size_type) [with _CharT = char; _Traits =
std::char_traits<char>; _Alloc = std::allocator<char>]'
2458 | replace(size_type __pos1, size_type __n1, const _Tp& __svt,
| ^~~~~~~
../Playground/++../Playground/:2458:9: note: template argument
deduction/substitution failed:
./Playground/file0.cpp:23:14: note: candidate expects 5 arguments, 2
provided
23 | s.replace("a", "");
| ~~~~~~~~~^~~~~~~~~
../Playground/++../Playground/:2480:9: note: candidate: 'template<class _Tp>
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp,
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&>
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(const_iterator,
const_iterator, const _Tp&) [with _CharT = char; _Traits =
std::char_traits<char>; _Alloc = std::allocator<char>]'
2480 | replace(const_iterator __i1, const_iterator __i2, const _Tp&
__svt)
| ^~~~~~~
../Playground/++../Playground/:2480:9: note: template argument
deduction/substitution failed:
./Playground/file0.cpp:23:14: note: candidate expects 3 arguments, 2
provided
23 | s.replace("a", "");
| ~~~~~~~~~^~~~~~~~~
../Playground/++../Playground/:2118:7: note: candidate:
'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type,
size_type, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with
_CharT = char; _Traits = std::char_traits<char>; _Alloc =
std::allocator<char>; size_type = long unsigned int]'
2118 | replace(size_type __pos, size_type __n, const basic_string&
__str)
| ^~~~~~~
../Playground/++../Playground/:2118:7: note: candidate expects 3 arguments,
2 provided
../Playground/++../Playground/:2141:7: note: candidate:
'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type,
size_type, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&,
size_type, size_type) [with _CharT = char; _Traits = std::char_traits<char>;
_Alloc = std::allocator<char>; size_type = long unsigned int]'
2141 | replace(size_type __pos1, size_type __n1, const basic_string&
__str,
| ^~~~~~~
../Playground/++../Playground/:2141:7: note: candidate expects 5 arguments,
2 provided
../Playground/++../Playground/:2167:7: note: candidate:
'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type,
size_type, const _CharT*, size_type) [with _CharT = char; _Traits =
std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long
unsigned int]'
2167 | replace(size_type __pos, size_type __n1, const _CharT* __s,
| ^~~~~~~
../Playground/++../Playground/:2167:7: note: candidate expects 4 arguments,
2 provided
../Playground/++../Playground/:2193:7: note: candidate:
'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type,
size_type, const _CharT*) [with _CharT = char; _Traits =
std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long
unsigned int]'
2193 | replace(size_type __pos, size_type __n1, const _CharT* __s)
| ^~~~~~~
../Playground/++../Playground/:2193:7: note: candidate expects 3 arguments,
2 provided
../Playground/++../Playground/:2218:7: note: candidate:
'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type,
size_type, size_type, _CharT) [with _CharT = char; _Traits =
std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long
unsigned int]'
2218 | replace(size_type __pos, size_type __n1, size_type __n2, _CharT
__c)
| ^~~~~~~
../Playground/++../Playground/:2218:7: note: candidate expects 4 arguments,
2 provided
../Playground/++../Playground/:2237:7: note: candidate:
'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&
std::__cxx11::basic_string<_CharT, _Traits,
_Alloc>::replace(__const_iterator, __const_iterator, const
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char;
_Traits = std::char_traits<char>; _Alloc = std::allocator<char>;
__const_iterator = std::__cxx11::basic_string<char>::const_iterator]'
2237 | replace(__const_iterator __i1, __const_iterator __i2,
| ^~~~~~~
../Playground/++../Playground/:2237:7: note: candidate expects 3 arguments,
2 provided
../Playground/++../Playground/:2258:7: note: candidate:
'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&
std::__cxx11::basic_string<_CharT, _Traits,
_Alloc>::replace(__const_iterator, __const_iterator, const _CharT*,
size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc =
std::allocator<char>; __const_iterator =
std::__cxx11::basic_string<char>::const_iterator; size_type = long unsigned
int]'
2258 | replace(__const_iterator __i1, __const_iterator __i2,
| ^~~~~~~
../Playground/++../Playground/:2258:7: note: candidate expects 4 arguments,
2 provided
../Playground/++../Playground/:2281:7: note: candidate:
'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&
std::__cxx11::basic_string<_CharT, _Traits,
_Alloc>::replace(__const_iterator, __const_iterator, const _CharT*) [with
_CharT = char; _Traits = std::char_traits<char>; _Alloc =
std::allocator<char>; __const_iterator =
std::__cxx11::basic_string<char>::const_iterator]'
2281 | replace(__const_iterator __i1, __const_iterator __i2, const
_CharT* __s)
| ^~~~~~~
../Playground/++../Playground/:2281:7: note: candidate expects 3 arguments,
2 provided
../Playground/++../Playground/:2303:7: note: candidate:
'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&
std::__cxx11::basic_string<_CharT, _Traits,
_Alloc>::replace(__const_iterator, __const_iterator, size_type, _CharT) [with
_CharT = char; _Traits = std::char_traits<char>; _Alloc =
std::allocator<char>; __const_iterator =
std::__cxx11::basic_string<char>::const_iterator; size_type = long unsigned
int]'
2303 | replace(__const_iterator __i1, __const_iterator __i2, size_type
__n,
| ^~~~~~~
../Playground/++../Playground/:2303:7: note: candidate expects 4 arguments,
2 provided
../Playground/++../Playground/:2362:7: note: candidate:
'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&
std::__cxx11::basic_string<_CharT, _Traits,
_Alloc>::replace(__const_iterator, __const_iterator, _CharT*, _CharT*) [with
_CharT = char; _Traits = std::char_traits<char>; _Alloc =
std::allocator<char>; __const_iterator =
std::__cxx11::basic_string<char>::const_iterator]'
2362 | replace(__const_iterator __i1, __const_iterator __i2,
| ^~~~~~~
../Playground/++../Playground/:2362:7: note: candidate expects 4 arguments,
2 provided
../Playground/++../Playground/:2374:7: note: candidate:
'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&
std::__cxx11::basic_string<_CharT, _Traits,
_Alloc>::replace(__const_iterator, __const_iterator, const _CharT*, const
_CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc =
std::allocator<char>; __const_iterator =
std::__cxx11::basic_string<char>::const_iterator]'
2374 | replace(__const_iterator __i1, __const_iterator __i2,
| ^~~~~~~
../Playground/++../Playground/:2374:7: note: candidate expects 4 arguments,
2 provided
../Playground/++../Playground/:2386:7: note: candidate:
'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&
std::__cxx11::basic_string<_CharT, _Traits,
_Alloc>::replace(__const_iterator, __const_iterator, iterator, iterator)
[with _CharT = char; _Traits = std::char_traits<char>; _Alloc =
std::allocator<char>; __const_iterator =
std::__cxx11::basic_string<char>::const_iterator; iterator =
std::__cxx11::basic_string<char>::iterator]'
2386 | replace(__const_iterator __i1, __const_iterator __i2,
| ^~~~~~~
../Playground/++../Playground/:2386:7: note: candidate expects 4 arguments,
2 provided
../Playground/++../Playground/:2398:7: note: candidate:
'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&
std::__cxx11::basic_string<_CharT, _Traits,
_Alloc>::replace(__const_iterator, __const_iterator, const_iterator,
const_iterator) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc
= std::allocator<char>; __const_iterator =
std::__cxx11::basic_string<char>::const_iterator; const_iterator =
std::__cxx11::basic_string<char>::const_iterator]'
2398 | replace(__const_iterator __i1, __const_iterator __i2,
| ^~~~~~~
../Playground/++../Playground/:2398:7: note: candidate expects 4 arguments,
2 provided
../Playground/++../Playground/:2424:21: note: candidate:
'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(const_iterator,
const_iterator, std::initializer_list<_Tp>) [with _CharT = char; _Traits =
std::char_traits<char>; _Alloc = std::allocator<char>; const_iterator =
std::__cxx11::basic_string<char>::const_iterator]'
2424 | basic_string& replace(const_iterator __i1, const_iterator __i2,
| ^~~~~~~
../Playground/++../Playground/:2424:21: note: candidate expects 3
arguments, 2 provided
:(((
作者: Wardyal (Wardyal)   2024-01-08 15:02:00
:(
作者: cpblgu (《超絕望級的cpblgu!》)   2024-01-08 15:02:00
教授 我文組ㄟ==
作者: lturtsamuel (港都都教授)   2024-01-08 15:02:00
:(((
作者: yam276 ('_')   2024-01-08 15:03:00
這就是為什麼你們應該學Rust至少連錯誤訊息都講人話
作者: devilkool (對貓毛過敏的貓控)   2024-01-08 15:07:00
void haha

Links booklink

Contact Us: admin [ a t ] ucptt.com