1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
template <class Char>
struct check_and_remove
{
private:
std::basic_string<Char>& base;
public:
check_and_remove(std::basic_string<Char>& b) : base(b) { }
void operator()(Char c)
{
if (std::count(str.begin(), str.end(), c))
{
str.erase(std::remove(str.begin(), str.end(), c), str.end());
}
}
};
template <class Char>
std::basic_string<Char> traite_chaine(
const std::basic_string<Char>& in,
const std::basic_string<Char>& chk)
{
std::basic_string<Char> out(in);
std::for_each(chk.begin(), chk.end(), check_and_remove<Char>(out));
return out;
} |
Partager