Open In App
Related Articles

list pop_front() function in C++ STL

Improve Article
Save Article
Like Article

The list::pop_front() is a built-in function in C++ STL which is used to remove an element from the front of a list container. This function thus decreases the size of the container by 1 as it deletes the element from the front of the list.




  • The function does not accept any parameter.

Return Value

  • This function does not return anything.


The below program illustrates the list::pop_front() function in C++ STL.


// CPP program to illustrate the
// list::pop_front() function
#include <bits/stdc++.h>
using namespace std;
int main()
    // Creating a list
    list<int> demoList;
    // Adding elements to the list
    // using push_back()
    // Initial List:
    cout << "Initial List: ";
    for (auto itr = demoList.begin(); itr != demoList.end();
        cout << *itr << " ";
    // removing an element from the front of List
    // using pop_front
    // List after removing element from front
    cout << "\n\nList after removing an element from "
            "front: ";
    for (auto itr = demoList.begin(); itr != demoList.end();
        cout << *itr << " ";
    return 0;


Initial List: 10 20 30 40 

List after removing an element from front: 20 30 40 

Time Complexity: O(n)
Auxiliary Space: O(1)

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 30 May, 2023
Like Article
Save Article
Similar Reads