C++ åèæå
- C++11
- C++14
- C++17
- C++20
- C++ ç¼è¯å¨æ¯ææ åµè¡¨
- ç¬ç«ä¸å®¿ä¸»å®ç°
- C++ è¯è¨
- C++ å ³é®è¯
- é¢å¤çå¨
- C++ æ ååºå¤´æä»¶
- å ·åè¦æ±
- åè½ç¹æ§æµè¯ (C++20)
- å·¥å ·åº
- ç±»åæ¯æï¼åºæ¬ç±»åãRTTIãç±»åç¹æ§ï¼
- æ¦å¿µåº (C++20)
- é误å¤ç
- 卿å å管ç
- æ¥æåæ¶é´å·¥å ·
- å符串åº
- 容å¨åº
- std::array
- std::vector
- std::map
- std::unordered_map
- std::priority_queue
- std::span
- std::forward_list
- std::forward_list<T,Allocator>::forward_list
- std::forward_list<T,Allocator>::~forward_list
- std::forward_list<T,Allocator>::operator=
- std::forward_list<T,Allocator>::unique
- std::forward_list<T,Allocator>::reverse
- std::forward_list<T,Allocator>::sort
- std::forward_list çæ¨å¯¼æå¼
- std::forward_list<T,Allocator>::merge
- std::forward_list<T,Allocator>::splice_after
- std::forward_list<T,Allocator>::remove, remove_if
- operator==,!=,<,<=,>,>=,<=>(std::forward_list)
- std::swap(std::forward_list)
- std::erase, std::erase_if (std::forward_list)
- std::forward_list<T,Allocator>::swap
- std::forward_list<T,Allocator>::erase_after
- std::forward_list<T,Allocator>::push_front
- std::forward_list<T,Allocator>::emplace_front
- std::forward_list<T,Allocator>::pop_front
- std::forward_list<T,Allocator>::resize
- std::forward_list<T,Allocator>::empty
- std::forward_list<T,Allocator>::max_size
- std::forward_list<T,Allocator>::clear
- std::forward_list<T,Allocator>::insert_after
- std::forward_list<T,Allocator>::emplace_after
- std::forward_list<T,Allocator>::begin, std::forward_list<T,Allocator>::cbegin
- std::forward_list<T,Allocator>::end, std::forward_list<T,Allocator>::cend
- std::forward_list<T,Allocator>::assign
- std::forward_list<T,Allocator>::get_allocator
- std::forward_list<T,Allocator>::front
- std::forward_list<T,Allocator>::before_begin, cbefore_begin
- std::deque
- std::list
- std::set
- std::multiset
- std::multimap
- std::unordered_set
- std::unordered_multiset
- std::unordered_multimap
- std::stack
- std::queue
- std::vector<bool>
- ç»ç¹ææ (C++17)
- 注é
- è¿ä»£å¨åº
- èå´åº (C++20)
- ç®æ³åº
- æ°å¼åº
- è¾å ¥/è¾åºåº
- æä»¶ç³»ç»åº
- æ¬å°ååº
- æ£å表达å¼åº
- ååæä½åº
- çº¿ç¨æ¯æåº
- å®éªæ§ C++ ç¹æ§
- æç¨çèµæº
- ç´¢å¼
- std 符å·ç´¢å¼
- åç¨æ¯æ (C++20)
- C++ å ³é®è¯
ä½ç½®ï¼é¦é¡µ > C++ åèæå >容å¨åº >std::forward_list > std::forward_list<T,Allocator>::remove, remove_if
std::forward_list<T,Allocator>::remove, remove_if
| void remove( const T& value ); |
(C++11 èµ·) (C++20 å) |
|
| size_type remove( const T& value ); |
(C++20 èµ·) | |
| template< class UnaryPredicate > void remove_if( UnaryPredicate p ); |
(C++11 èµ·) (C++20 å) |
|
| template< class UnaryPredicate > size_type remove_if( UnaryPredicate p ); |
(C++20 èµ·) | |
ç§»é¤æææ»¡è¶³ç¹å®æ åçå
ç´ ã第ä¸çæ¬ç§»é¤ææçäº value çå
ç´ ï¼ç¬¬äºçæ¬ç§»é¤ææè°è¯ p 对å®è¿å true çå
ç´ ã
åæ°
| value | - | è¦ç§»é¤çå ç´ çå¼ |
| p | - | è¥åºè¯¥ç§»é¤è¯¥å
ç´ åè¿å âtrue çä¸å
è°è¯ã 对æ¯ä¸ªï¼å¯ä¸º const çï¼ |
è¿åå¼
|
ï¼æ ï¼ |
(C++20 å) |
|
ç§»é¤çå ç´ æ°ã |
(C++20 èµ·) |
å¤æåº¦
ä¸å®¹å¨å¤§å°æçº¿æ§
示ä¾
è¿è¡æ¤ä»£ç
#include <forward_list> #include <iostream>  int main() { std::forward_list<int> l = { 1,100,2,3,10,1,11,-1,12 };  l.remove(1); // ç§»é¤ä¸¤ä¸ªçäº 1 çå ç´ l.remove_if([](int n){ return n > 10; }); // ç§»é¤å ¨é¨å¤§äº 10 çå ç´ Â for (int n : l) { std::cout << n << ' '; } std::cout << '\n'; }
è¾åºï¼
2 3 10 -1
åé
| ç§»é¤æ»¡è¶³ç¹å®å¤å«æ åçå
ç´ (彿°æ¨¡æ¿) |