C++ Vector max_size
This function is utilized to determine the maximum capacity that a vector can contain.
Syntax
Consider a vector 'v' and a maximum size 'm'. The syntax should be as follows:
Example
int m=v.max_size();
Parameter
It does not contain any parameter.
Return value
It retrieves the highest number of elements that a vector is capable of containing.
Example 1
Let's see a simple example.
Example
#include <iostream>
#include<vector>
using namespace std;
int main()
{
vector<int> v{1,2,3,4,5};
std::cout<<v.max_size() <<std::endl;
return 0;
}
Output:
Output
4611686018427387903