名稱空間
變體
操作

std::flat_multiset<Key,Compare,KeyContainer>::max_size

來自 cppreference.com
 
 
 
 
size_type max_size() const noexcept;
(C++23 起)

返回容器能夠容納的最大元素數量,這取決於系統或庫實現的限制,即對於最大的容器來說,是 std::distance(begin(), end())

目錄

[edit] 引數

(無)

[edit] 返回值

最大元素數量。

[edit] 複雜度

常數時間。

[edit] 注意

此值通常反映了容器大小的理論限制,最多為 std::numeric_limits<difference_type>::max()。在執行時,容器的大小可能會因可用RAM的數量而限制為小於 max_size() 的值。

[edit] 示例

#include <iostream>
#include <flat_set>
#include <locale>
 
int main()
{
    std::flat_multiset<char> q;
    std::cout.imbue(std::locale("en_US.UTF-8"));
    std::cout << "Maximum size of a std::flat_multiset is " << q.max_size() << '\n';
}

可能的輸出

Maximum size of a std::flat_multiset is 768,614,336,404,564,650

[edit] 參閱

返回元素數量
(公共成員函式) [編輯]