public member function
<set>
std::set::max_sizesize_type max_size() const;
size_type max_size() const noexcept;
Return maximum size
Returns the maximum number of elements that the set container can hold.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.
Member type size_type is an unsigned integral type.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// set::max_size
#include <iostream>
#include <set>
int main ()
{
int i;
std::set<int> myset;
if (myset.max_size()>1000)
{
for (i=0; i<1000; i++) myset.insert(i);
std::cout << "The set contains 1000 elements.\n";
}
else std::cout << "The set could not hold 1000 elements.\n";
return 0;
}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4