std::experimental::erase (std::vector)
ja.cppreference.net より
template< class T, class A, class U >
void erase( std::vector<T, 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/vector> #include <iostream> auto show = [](const auto& container) { for (auto e : container) std::cout << e; std::cout << '\n'; }; int main() { std::vector<int> data{1, 1, 1, 4, 1, 1, 1, 2, 1, 1, 1}; show(data); std::experimental::erase(data, 1); show(data); }
出力:
11141112111 42
関連項目
| 特定の基準を満たす要素を削除する (関数テンプレート & アルゴリズム関数オブジェクト) | |
(C++20)(C++20) |
|
(library fundamentals 2 TS) |
消去する述語を満たすすべての要素をある std::vector (関数テンプレート) |