list_pop_front
list_pop_front (std::list::pop_front — 앞 원소 제거)
std::list의 첫 번째 원소를 제거하는 멤버 함수예요.
출처: cppreference
본문
시그니처는 다음과 같아요.
void pop_front();
컨테이너의 첫 번째 원소를 제거해요.
empty()가 true이면 동작이 정의되지 않아요. (until C++26) C++26부터는 empty()가 true일 때 하드닝된 구현이면 계약 위반이 발생하고, 아니면 동작이 정의되지 않아요.
지워진 원소에 대한 참조와 이터레이터는 무효화돼요.
복잡도
상수(constant)예요.
예제
#include <list>
#include <iostream>
int main()
{
std::list<char> chars{'A', 'B', 'C', 'D'};
for (; !chars.empty(); chars.pop_front())
std::cout << chars.front() << ' '; // A B C D
}
함께 보기
push_front: 앞에 원소를 삽입해요