Namespaces
Variants

std::deque<T,Allocator>:: pop_front

From cppreference.net

void pop_front ( ) ;
(constexpr C++26부터)

컨테이너의 첫 번째 요소를 제거합니다.

만약 empty() true 라면, 동작은 정의되지 않습니다.

(C++26 이전)

만약 empty() true 라면:

  • 구현이 hardened 된 경우, contract violation 이 발생합니다. 또한 계약 위반 핸들러가 "observe" 평가 의미론 하에 반환한다면, 동작은 정의되지 않습니다.
  • 구현이 hardened 되지 않은 경우, 동작은 정의되지 않습니다.
(C++26 이후)

삭제된 요소에 대한 반복자와 참조는 무효화됩니다. 만약 해당 요소가 컨테이너의 마지막 요소인 경우, end() 반복자 또한 무효화됩니다. 다른 참조와 반복자들은 영향을 받지 않습니다.

복잡도

상수.

예제

#include <deque>
#include <iostream>
int main()
{
    std::deque<char> chars{'A', 'B', 'C', 'D'};
    for (; !chars.empty(); chars.pop_front())
        std::cout << "chars.front(): '" << chars.front() << "'\n";
}

출력:

chars.front(): 'A'
chars.front(): 'B'
chars.front(): 'C'
chars.front(): 'D'

참고 항목

마지막 요소를 제거합니다
(public member function)
시작 부분에 요소를 삽입합니다
(public member function)
첫 번째 요소에 접근합니다
(public member function)