string_algo no replace_if

Dear all I was requesting an 'erase_if' a while ago, and now I ran into a 'replace_if' problem. So after spendig 2 hours in the documentation, I finally found on www ('[string_algo] replace repeated char with single instance?') that one should use the 'find_format_all': boost::find_format_all(str, boost::token_finder(boost::is_any_of("ab")), boost::const_formatter("c")); But wouldn't it be better to make a 'replace_if' shortcut solely for the purpose of documentation reasons: boost::replace_all_if(str, boost::is_any_of("ab"), "c"); I think that most people find the last line easier to read and comprehend than its (more powerful) 'find_format' cousin. The string_algo library is nice but I get lost more than once. Especially find, replace, erease with predicates are often used by us. However direct use seems not possible. wkr, me

Hi, I think that your arguments are reasonable. Even if I don't like to extend the number of find/erase/replace functions very much. I'll put it on my todo list, but I cannot promise when it actually be implemented. Reagards, Pavol. gast128 wrote:
Dear all
I was requesting an 'erase_if' a while ago, and now I ran into a 'replace_if' problem. So after spendig 2 hours in the documentation, I finally found on www ('[string_algo] replace repeated char with single instance?') that one should use the 'find_format_all':
boost::find_format_all(str, boost::token_finder(boost::is_any_of("ab")), boost::const_formatter("c"));
But wouldn't it be better to make a 'replace_if' shortcut solely for the purpose of documentation reasons:
boost::replace_all_if(str, boost::is_any_of("ab"), "c");
I think that most people find the last line easier to read and comprehend than its (more powerful) 'find_format' cousin. The string_algo library is nice but I get lost more than once. Especially find, replace, erease with predicates are often used by us. However direct use seems not possible.
wkr, me
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Pavol Droba
Hi,
I think that your arguments are reasonable. Even if I don't like to extend the number of find/erase/replace functions very much.
I'll put it on my todo list, but I cannot promise when it actually be implemented.
Reagards, Pavol.
ok that would be nice. One character replacement could also be achieved by using std::replace_if: std::replace_if(str4.begin(), str4.end(), boost::is_any_of("ab"), _T('c')); But then again putting this in string_algo (with its extra power) would be better.
participants (2)
-
gast128
-
Pavol Droba