目录

forward_list::max_size

描述 (Description)

C ++函数std::forward_list::max_size()返回forward_list可以保存的最大元素数。 此值取决于系统或库实现。

声明 (Declaration)

以下是std :: forward_list :: max_size()函数形式std :: forward_list头的声明。

C++11

size_type max_size () const noexcept;

参数 (Parameters)

没有

返回值

返回可以放入forward_list的最大数字。

异常 (Exceptions)

该成员函数从不抛出异常。

时间复杂

常数即O(1)

例子 (Example)

以下示例显示了std :: forward_list :: max_size()函数的用法。

#include <iostream>
#include <forward_list>
using namespace std;
int main(void) {
   forward_list<int> fl;
   cout << "max_size of list = " << fl.max_size() << endl;
   return 0;
}

让我们编译并运行上面的程序,这将产生以下结果 -

max_size of list = 1152921504606846975
↑回到顶部↑
WIKI教程 @2018