Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximum size of std::size and std::map?

What is maximum size of std::size and std::map? And is there a way to increase this number?

Thanks!

like image 778
Roman Avatar asked Feb 19 '23 17:02

Roman


2 Answers

You can get maximum size of every standard library container by calling Container::max_size() on it. If you need theoretical maximum size value at compile time, use std::numeric_limits<Container::size_type>::max().

like image 72
Griwes Avatar answered Feb 21 '23 07:02

Griwes


Maximum size of any standard container is given by container<T>::max_size() method. In general case, this size might (and will) be smaller than the range of container<T>::size_type.

The range of container::size_type can be obtained through std::numeric_limits, but, again, keep in mind that containers do not guarantee that their maximum size can reach the full range of their size_type.

Note also that container<T>::max_size() returns the maximum number of elements in the container, while std::numeric_limits<container<T>::size_type>::max() returns the range of the size_type. These are incomparable values.

like image 34
AnT Avatar answered Feb 21 '23 07:02

AnT