forward_list::max_size() in C++ STL

std::forward_list::max_size() is an inbuilt function in CPP STL which returns the maximum number of elements can be held by forward_list. This value depends on system or library implementation.

Syntax:

forwardlist_name.max_size ()

Parameters: The function does not accept any parameters.

Return value:The function returns the maximum numbers that can be stored into the forward_list.

Below program demonstrates the above function:

filter_none

edit
close

play_arrow

link
brightness_4
code

// C++ program to illustrate the
// max_size() function
#include <bits/stdc++.h>
using namespace std;
  
int main()
{
    // initialising the forward list
    forward_list<int> f;
  
    // print max number of values that 
    // can be held by forward_list
    cout << "Max_size of the list is " 
    << f.max_size() << endl;
  
    return 0;
}

chevron_right


Output:

Max_size of the list is 1152921504606846975

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.