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

However, to work out the maximum length of a string in general, the programmer has to create a (possibly empty) string object.