std::experimental:: erase (std::forward_list)
|
ヘッダーで定義
<experimental/forward_list>
|
||
|
template
<
class
T,
class
A,
class
U
>
void erase ( std:: forward_list < T, A > & c, const U & value ) ; |
(ライブラリ基盤仕様 TS v2) | |
コンテナから value と等しい比較結果となる全ての要素を削除します。以下と等価です: c. remove_if ( [ & ] ( auto & elem ) { return elem == value ; } ) ; 。
目次 |
パラメータ
| c | - | 消去元のコンテナ |
| value | - | 削除する値 |
計算量
線形。
例
#include <experimental/forward_list> #include <iostream> auto show = [](const auto& container) { for (auto e : container) std::cout << e; std::cout << '\n'; }; int main() { std::forward_list<int> data{1, 1, 1, 4, 1, 1, 1, 2, 1, 1, 1}; show(data); std::experimental::erase(data, 1); show(data); }
出力:
11141112111 42
注記
std::forward_list::remove とは異なり、この関数テンプレートは異種型を受け入れ、コンテナの値型への変換を強制せずに == 演算子を呼び出します。
関連項目
|
特定の条件を満たす要素を削除する
(関数テンプレート) |
|
|
特定の条件を満たす要素を削除する
(
std::forward_list<T,Allocator>
の公開メンバ関数)
|
|
|
(library fundamentals 2 TS)
|
述語を満たすすべての要素を
std::forward_list
から削除する
(関数テンプレート) |