English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C ++ The List max_size() function determines the maximum size of the list. This function does not change the size of the list.
size_type max_size();
It does not contain any parameters.
It returns the maximum number of elements that the list can contain.
Let's see a simple example
#include<iostream> #include<list> using namespace std; int main() { list<int> li={9,10,11 std::cout << "The size of the list is: " << li.max_size() << std::endl; return 0;
Output:
The size of the list is: 357913941
In this example, the max_size() function returns the maximum size that the list can accommodate.