最終更新日時(UTC):
が更新

履歴 編集

function
<string>

std::basic_string::max_size

size_type max_size() const;                    // (1) C++03
size_type max_size() const noexcept;           // (1) C++11
constexpr size_type max_size() const noexcept; // (1) C++20

概要

格納可能な最大の文字列長を取得する。

戻り値

格納可能な最大の文字列長。

例外

投げない

計算量

定数時間

#include <iostream>
#include <string>

int main()
{
  std::string s;
  std::size_t n = s.max_size();

  std::cout << n << std::endl;
}

出力例

4611686018427387897

参照