vector max_size() function in C++ STL
The vector::max_size() is a built-in function in C++ STL which returns the maximum number of elements that can be held by the vector container.
Parameters: The function does not accept any parameters.
Return value: The function returns the maximum numbers that can fit into the vector container.
Time Complexity – Constant O(1)
Program below illustrates the above function:
cout << "max_size of vector 1 = " << vec.max_size() << endl;
cout << "max_size of vector 2 = " << vec1.max_size() << endl;
max_size of vector 1 = 4611686018427387903
max_size of vector 2 = 4611686018427387903
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!