C++ list pop_front() function

Last Updated : 14 May 2026

List pop_front() Function

In C++, the list::pop_front() function is used to remove the first element from the list container. After removing the element, the size of the list decreases by one. Since the list container is implemented as a doubly linked list, the pop_front() operation works in constant time complexity O(1).

This function is commonly used in queues, buffers, and sequential data processing where elements are removed from the beginning of the list.

Syntax:

It has the following syntax:

Parameters

It represents the name of the list from which we want the first item deleted.

Return Value

It does not return any value.

Examples of List pop_front() Function

Here, we are going to discuss several examples to demonstrate the List pop_front() Function

Example 1: Remove the First Element from a List

This example demonstrates how to remove the first element from a list using the pop_front() function.

Output:

Original list: 10 20 30 40 
List after pop_front(): 20 30 40

Explanation:

In this example, we have initialized a list named numbers with 4 integer elements. After that, we use the pop_front() function to remove the first element (10) from the list. After executing this operation, the remaining elements 20, 30, and 40 are displayed, which shows that the size of the list has decreased by one.

Example 2: Remove the First String Element from a List

This example demonstrates how to remove the first string element from a list using the pop_front() function.

Output:

Fruits list before pop_front(): Apple Banana Cherry Mango 
Fruits list after pop_front(): Banana Cherry Mango

Explanation:

In the given example, we have created a list of fruits that is a list of strings whose first four members are Apple, Banana, Cherry, and Mango. After executing the pop_front() function, the list is without its first member, i.e., Apple. Therefore, the std::list is a linked list, and the other members conceptually shift forward. Finally, the new list now has the elements of Banana, Cherry, and Mango.