#include <algorithm>
#include <string>
void foo(std::string &s) {
replace(s.begin(), s.end(), 'S', 'TH');
}
I want foo(s)
to replace each S
in s
with the two characters TH
. For example
std::string s = "SAT";
foo(s);
std::cout << s << "\n" // THAT
However, the definition of foo
gives me an error.
Error (active) E0304 no instance of function template "std::replace" matches the argument list
Why does this not work?