How to Check if a List is Empty in C++? Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report In C++, a list is a sequence container that allows non-contiguous memory allocation and is implemented using a doubly linked list. In this article, we will learn how to check if a list is empty in C++. Example: Input: myList = {1, 2, 3}; Output: List is not empty.Check if a List is Empty in C++To check if a std::list is empty or not, we can use the std::list::empty() function that returns true if the list is empty and returns false if the list is not empty. C++ Program to Check if a List is EmptyThe below example demonstrates how we can use the empty() function to check if the given list is empty or not in C++ STL. C++ // C++ Program to illustrate how to check if a list is empty #include <iostream> #include <list> using namespace std; int main() { // Initialize a list list<int> myList = { 1, 2, 3 }; // Check if the list is empty bool isEmpty = myList.empty(); // Print the result if (isEmpty) { cout << "List is empty" << endl; } else { cout << "List is not empty" << endl; } return 0; } OutputList is not empty Time Complexity: O(1) Auxiliary Space: O(1) Note: We can also use std::list::size() function to check if the given list is empty or not in C++. Comment S sravankumar_171fa07058 Follow Improve S sravankumar_171fa07058 Follow Improve Article Tags : C++ Programs C++ cpp-list CPP Examples Explore C++ BasicsIntroduction to C++3 min readData Types in C++6 min readVariables in C++4 min readOperators in C++9 min readBasic Input / Output in C++3 min readControl flow statements in Programming15+ min readLoops in C++7 min readFunctions in C++8 min readArrays in C++8 min readCore ConceptsPointers and References in C++5 min readnew and delete Operators in C++ For Dynamic Memory5 min readTemplates in C++8 min readStructures, Unions and Enumerations in C++3 min readException Handling in C++12 min readFile Handling in C++8 min readMultithreading in C++8 min readNamespace in C++5 min readOOP in C++Object Oriented Programming in C++8 min readInheritance in C++6 min readPolymorphism in C++5 min readEncapsulation in C++4 min readAbstraction in C++4 min readStandard Template Library(STL)Standard Template Library (STL) in C++3 min readContainers in C++ STL3 min readIterators in C++ STL10 min readC++ STL Algorithm Library3 min readPractice & ProblemsC++ Interview Questions and Answers1 min readC++ Programming Examples4 min read Like