18 std::string&
erase_all(std::string* str,
char drop) {
19 std::string::size_type pos1 = std::string::npos, pos2;
21 while ((pos1 = str->find_last_of(drop, pos1)) != std::string::npos) {
22 pos2 = str->find_last_not_of(drop, pos1);
23 if (pos2 == std::string::npos) {
24 str->erase(0, pos1 - pos2);
27 str->erase(pos2 + 1, pos1 - pos2);
34 std::string&
erase_all(std::string* str,
const char* drop) {
35 std::string::size_type pos1 = std::string::npos, pos2;
37 while ((pos1 = str->find_last_of(drop, pos1)) != std::string::npos) {
38 pos2 = str->find_last_not_of(drop, pos1);
39 if (pos2 == std::string::npos) {
40 str->erase(0, pos1 - pos2);
43 str->erase(pos2 + 1, pos1 - pos2);
50 std::string&
erase_all(std::string* str,
const std::string& drop) {
57 std::string
erase_all(
const std::string& str,
char drop) {
59 out.reserve(str.size());
61 std::string::const_iterator si = str.begin();
62 while (si != str.end()) {
71 std::string
erase_all(
const std::string& str,
const char* drop) {
73 out.reserve(str.size());
75 std::string::const_iterator si = str.begin();
76 while (si != str.end()) {
92 std::string
erase_all(
const std::string& str,
const std::string& drop) {
std::string & erase_all(std::string *str, char drop)
Remove all occurrences of the given character in-place.