Why isn't std::string::max_size a compile-time constant?

后端 未结 4 1298
情书的邮戳
情书的邮戳 2021-01-03 18:22

std::string provides a max_size() method to determine the maximum number of elements it can contain.

However, to work out the maximum lengt

4条回答
  •  南方客
    南方客 (楼主)
    2021-01-03 18:39

    The call to max_size() is delegated to the allocator used for the container.

    In theory, a very smart allocator could compute its max_size in runtime, e.g. depending on RAM available.

提交回复
热议问题