STL vector中的max_size方法
程序员文章站
2022-05-24 13:21:25
...
public member function
<vector>
std::vector::max_size
Return maximum size
Returns the maximum number of elements that the vector can hold.返回vector所能储存的最大的元素数目。
This is the maximum potential size the container can reach due to known system or library implementation limitations, but the container is by no means guaranteed to be able to reach that size: it can still fail to allocate storage at any point before that size is reached.
容器所能容纳的最大元素数目,这是系统或者库所实施的限制。但是容器不一定保证能达到该大小,有可能在还未达到该大小的时候,就已经无法继续分配任何的空间了。
Parameters
noneReturn Value
The maximum number of elements a vector container can hold as content.容器所能容纳的最大数目的元素个数。
Example
|
|
A possible output for this program could be:
size: 100
capacity: 128
max_size: 1073741823
|
运行截图:
Complexity
Constant.Iterator validity
No changes.Data races
The container is accessed.
容器将被访问。
No contained elements are accessed: concurrently accessing or modifying them is safe.
容器内的元素不会被访问,同时访问以及修改他们也是安全的。
Exception safety
No-throw guarantee: this member function never throws exceptions.
该方法不会抛出异常。
上一篇: Android 颜色使用总结
下一篇: Highcharts的饼图大小的控制