Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

std::string::max_size() as static member

Tags:

c++

std

Why isn't max_size a static member of std::string?

This compiles but I think its strange that a property common to all strings can only be accessed via an instance of a string:

std::size_t max_size = std::string().max_size();

Why is it implemented like this?

like image 331
Baz Avatar asked Nov 28 '12 10:11

Baz


1 Answers

Why isn't max_size a static member of std::string?

Because max_size return value depends on the allocator instance that the string instance uses internally.

like image 109
utnapistim Avatar answered Oct 06 '22 02:10

utnapistim