std::list<T,Allocator>::remove, remove_if
提供: cppreference.com
void remove(const T& value ); | (C++20未満) | |
size_type remove(const T& value ); | (C++20以上) | |
template<class UnaryPredicate > void remove_if( UnaryPredicate p ); | (C++20未満) | |
template<class UnaryPredicate > size_type remove_if( UnaryPredicate p ); | (C++20以上) | |
特定の条件を満たすすべての要素を削除します。 最初のバージョンは value
と等しいすべての要素を削除します。 2番目のバージョンは述語 p
が true を返すすべての要素を削除します。
目次 |
[編集]引数
value | - | 削除する要素の値 |
p | - | 要素が削除されるべき場合に true を返す単項述語。 式 p(v) は |
[編集]戻り値
(なし) | (C++20未満) |
削除された要素の数。 | (C++20以上) |
[編集]計算量
コンテナのサイズに比例。
[編集]例
Run this code
出力:
2 3 10 -1
[編集]関連項目
一定の基準を満たす要素を削除します (関数テンプレート) |