table of contents
std::experimental::erase(std::basic_string)(3) | C++ Standard Libary | std::experimental::erase(std::basic_string)(3) |
NAME¶
std::experimental::erase(std::basic_string) - std::experimental::erase(std::basic_string)
Synopsis¶
Defined in header <experimental/string>
template< class CharT, class Traits, class A, class U
> (library fundamentals TS v2)
void erase( std::basic_string<CharT, Traits, A>& c,
const U& value );
Erases all elements that compare equal to value from the container.
Equivalent to
c.erase(std::remove(c.begin(), c.end(), value), c.end());.
Parameters¶
c - container from which to erase
value - value to be removed
Complexity¶
Linear.
Example¶
// Run this code
#include <experimental/string>
#include <iostream>
int main()
{
std::string data{"$$P$A$S$S$$W$O$R$$D$"};
std::cout << data << '\n';
auto crack{'$'};
std::experimental::erase(data, crack);
std::cout << data << '\n';
}
Output:¶
$$P$A$S$S$$W$O$R$$D$
PASSWORD
See also¶
remove removes elements satisfying specific criteria
remove_if (function template)
erase_if (std::basic_string) erases all elements satisfying a predicate from
a
(library fundamentals 2 TS) std::basic_string
(function template)
2024.06.10 | http://cppreference.com |