std::experimental::erase (std::basic_string)
ja.cppreference.net から
template< class CharT, class Traits, class A, class U >
void erase( std::basic_string<CharT, Traits, A>& c, const U& value );
|
(library fundamentals TS v2) で定義 | |
value に等しいすべての要素をコンテナから消去します。c.erase(std::remove(c.begin(), c.end(), value), c.end()); と同等です。
パラメータ
| c | - | 要素を削除するコンテナ |
| value | - | 削除する値 |
計算量
線形。
例
このコードを実行
#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'; }
出力:
$$P$A$S$S$$W$O$R$$D$ PASSWORD
関連項目
| 特定の条件を満たす要素を削除する (関数テンプレート & アルゴリズム関数オブジェクト) | |
(C++20)(C++20) |
|
(library fundamentals 2 TS) |
述語を満たすすべての要素を std::basic_string から削除する(関数テンプレート) |