STL_examples.cpp
TEST(remove_if, ExampleOne) {
    std::string s = "*h_e_*l_l*_o";
    const auto isNotLowercaseLetter = [](unsigned char c)->bool{ return !(c >= 'a' && c <= 'z'); };
    std::remove_if(s.begin(), s.end(), isNotLowercaseLetter);
    EXPECT_EQ(s, "hello*l_l*_o");

    // Using erase-remove idiom:
    std::string s2 = "*h_e_*l_l*_o";
    s2.erase(std::remove_if(s2.begin(), s2.end(), isNotLowercaseLetter), s2.end());
    EXPECT_EQ(s2, "hello");
}
// Note that remove_if_copy() also exists, which copies the range,
// omitting anything that doesn't fit the criteria.
Note that remove_if_copy() also exists, which copies the range,
omitting anything that doesn't fit the criteria.
Note that remove_if_copy () also exists which copies the range omitting anything that doesn ' t fit the criteria .
TEST(remove_if, ExampleOne) {
    std::string s = "*h_e_*l_l*_o";
    const auto isNotLowercaseLetter = [](unsigned char c)->bool{ return !(c >= 'a' && c <= 'z'); };
    std::remove_if(s.begin(), s.end(), isNotLowercaseLetter);
    EXPECT_EQ(s, "hello*l_l*_o");
    std::string s2 = "*h_e_*l_l*_o";
    s2.erase(std::remove_if(s2.begin(), s2.end(), isNotLowercaseLetter), s2.end());
    EXPECT_EQ(s2, "hello");
}
TEST ( remove_if , ExampleOne ) { std :: string s = " " ; const auto isNotLowercaseLetter = [ ] ( unsigned char c ) -> bool { return ! ( c >= ' ' && c <= ' ' ) ; } ; std :: remove_if ( s . begin ( ) , s . end ( ) , isNotLowercaseLetter ) ; EXPECT_EQ ( s , " " ) ; std :: string s2 = " " ; s2 . erase ( std :: remove_if ( s2 . begin ( ) , s2 . end ( ) , isNotLowercaseLetter ) , s2 . end ( ) ) ; EXPECT_EQ ( s2 , " " ) ; }
Note that remove_if_copy() also exists, which copies the range,
omitting anything that doesn't fit the criteria.
Note that remove_if_copy () also exists which copies the range omitting anything that doesn ' t fit the criteria .
// Using erase-remove idiom: