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:
CPP
#include <bits/stdc++.h>
using namespace std;
int main()
{
forward_list< int > f;
cout << "Max_size of the list is "
<< f.max_size() << endl;
return 0;
}
|
Output
Max_size of the list is 1152921504606846975
Time Complexity: O(1)
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!