Namespaces
Variants

std::experimental::erase_if (std::deque)

cppreference.net에서

 
 
실험적
기술 명세
파일 시스템 라이브러리 (filesystem TS)
라이브러리 기본 (library fundamentals TS)
라이브러리 기본 2 (library fundamentals TS v2)
라이브러리 기본 3 (library fundamentals TS v3)
병렬성 확장 (parallelism TS)
병렬성 확장 2 (parallelism TS v2)
동시성 확장 (concurrency TS)
동시성 확장 2 (concurrency TS v2)
개념 (concepts TS)
범위 (ranges TS)
리플렉션 (reflection TS)
수학 특수 함수 (special functions TR)
실험적 비TS
패턴 매칭
선형 대수
std::execution
계약
2D 그래픽
 
 
헤더에 정의됨 <experimental/deque>
template< class T, class Alloc, class Pred >
void erase_if( std::deque<T, Alloc>& c, Pred pred );
(library fundamentals TS v2)

술어(predicate)를 만족하는 모든 요소를 제거합니다. pred 컨테이너에서 제거합니다. 다음과 동일합니다: c.erase(std::remove_if(c.begin(), c.end(), pred), c.end());.

매개변수

c - 삭제할 컨테이너
pred - 어떤 요소를 삭제할지 결정하는 조건자

복잡도

선형.

예제

#include <experimental/deque>
#include <iostream>
template<typename Os, typename Container>
inline Os& operator<<(Os& os, Container const& container)
{
    os << "{ ";
    for (const auto& item : container)
        os << item << ' ';
    return os << '}';
}
int main()
{
    std::deque<int> data{3, 3, 4, 5, 5, 6, 6, 7, 2, 1, 0};
    std::cout << "Original:\n" << data << '\n';
    auto divisible_by_3 = [](auto const& x) { return (x % 3) == 0; };
    std::experimental::erase_if(data, divisible_by_3);
    std::cout << "Erase all items divisible by 3:\n" << data << '\n';
}

출력:

Original:
{ 3 3 4 5 5 6 6 7 2 1 0 }
Erase all items divisible by 3:
{ 4 5 5 7 2 1 }

참고

특정 조건을 만족하는 요소를 제거합니다
(함수 템플릿 & 알고리즘 함수 객체)
(라이브러리 기초 2 TS)
특정 값과 같은 모든 요소를 std::deque에서 지웁니다
(함수 템플릿)