◐ Shell
clean mode source ↗

std::unordered_set<Key,Hash,KeyEqual,Allocator>::max_size - cppreference.com

提供: cppreference.com

<tbody> </tbody>

size_type max_size() const noexcept;

(C++11以上)

システムまたはライブラリ実装の制限によるコンテナが保持できる最大要素数を返します。

引数

(なし)

戻り値

最大要素数。

計算量

一定。

ノート

この値は一般的にはコンテナのサイズの理論上の制限を反映します (多くとも std::numeric_limits<difference_type>::max())。 実行時の利用可能な RAM の量により、コンテナのサイズは max_size() より小さな値に制限される場合があります。

#include <iostream>
#include <unordered_set>

int main()
{
    std::unordered_set<char> s;
    std::cout << "Maximum size of a 'unordered_set' is " << s.max_size() << "\n";
}

出力例:

Maximum size of a 'unordered_set' is 768614336404564650

関連項目