std::experimental::erase (std::forward_list)
cppreference.net에서
< cpp | experimental
| 헤더에 정의됨 <experimental/forward_list>
|
||
template< class T, class A, class U >
void erase( std::forward_list<T, A>& c, const U& value );
|
(library fundamentals 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 와 달리, 이 함수 템플릿은 이종 타입을 허용하며 == 연산자를 호출하기 전에 컨테이너의 값 타입으로의 변환을 강제하지 않습니다.
참고 항목
| 특정 기준을 만족하는 요소를 제거합니다 (함수 템플릿 & 알고리즘 함수 객체) | |
(C++20)(C++20) |
|
| 특정 기준을 만족하는 요소를 제거합니다 (의 공개 멤버 함수 std::forward_list<T,Allocator>)
| |
(라이브러리 기초 2 TS) |
다음에서 조건자를 만족하는 모든 요소를 지웁니다 std::forward_list (함수 템플릿) |