std::flat_map<Key,T,Compare,KeyContainer,MappedContainer>::max_size
來自 cppreference.com
size_type max_size() const noexcept; |
(C++23 起) | |
返回容器由於系統或庫實現限制而能夠容納的最大元素數。等同於 std::min<size_type>(c.keys.max_size(), c.values.max_size())。
目錄 |
[edit] 引數
(無)
[edit] 返回值
最大元素數量。
[edit] 複雜度
常數時間。
[edit] 注意
此值通常反映容器大小的理論限制,最多為 std::numeric_limits<difference_type>::max()。在執行時,容器的大小可能會因可用 RAM 的數量而限制為小於 max_size()
的值。
[edit] 示例
執行此程式碼
#include <iostream> #include <flat_map> #include <locale> int main() { std::flat_map<char, char> q; std::cout.imbue(std::locale("en_US.UTF-8")); std::cout << "Maximum size of a std::flat_map is " << q.max_size() << '\n'; }
可能的輸出
Maximum size of a std::flat_map is 768,614,336,404,564,650
[edit] 參閱
返回元素數量 (public member function) |