📅  最后修改于: 2022-03-11 14:44:53.519000             🧑  作者: Mango
#include
#include
using namespace std;
template
void removeSubstrs(basic_string& s,
const basic_string& p) {
basic_string::size_type n = p.length();
for (basic_string::size_type i = s.find(p);
i != basic_string::npos;
i = s.find(p))
s.erase(i, n);
}
int main() {
string s = "One fish, two fish, red fish, blue fish";
string p = "fish";
removeSubstrs(s, p);
cout << s << '\n';
}
The basic_string member func