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

后端 未结 4 1214
情书的邮戳
情书的邮戳 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:42

    This should also work:

    enum : std::string::size_type {
        npos     = std::string::size_type(-1),
        max_size = npos - 1
    };
    

提交回复
热议问题