C++ vector max_size(); -
on 32 bit system.
std::vector<char>::max_size()
returns 232-1, size ofchar
— 1 bytestd::vector<int>::max_size()
returns 230-1, size ofint
— 4 bytestd::vector<double>::max_size()
returns 229-1, size ofdouble
— 8 byte
can tell me max_size()
depends on what?
and return value of max_size()
if runs on 64 bit system.
max_size()
theoretical maximum number of items put in vector. on 32-bit system, in theory allocate 4gb == 2^32 2^32 char
values, 2^30 int
values or 2^29 double
values. appear implementation using value, subtracting 1.
of course, never allocate vector big; you'll run out of memory long before then.
there no requirement on value max_size()
returns other cannot allocate vector bigger that. on 64-bit system might return 2^64-1 char
, or might return smaller value because system has limited memory space. 64-bit pcs limited 48-bit address space anyway.
Comments
Post a Comment