std::experi...asic_string)(3)
πΈ NAME πΈ
okay so bestie, this page is std::experi...asic_string)(3), folded in from the C++ Standard Libary manual (yes, "Libary," that's the header's spelling, no cap π
). NAME says std::experimental::erase(std::basic_string) - std::experimental::erase(std::basic_string) β yes, twice, and we love a repetitive queen. It's defined in header <experimental/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 );
This one is tagged (library fundamentals TS v2), bestie. It 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. Simple, clean, iconic. β¨
π§ 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 astd::basic_string(library fundamentals 2 TS) (function template).
cute sign-off: source/version is cppreference.com, 2024.06.10. stay slay, bestie π
π«Ά
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms