Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

std::tr1::array - What's the difference between max_size and size?

1 view
Skip to first unread message

Sarath

unread,
Aug 17, 2009, 9:49:15 AM8/17/09
to
From the documentaiton, I could not find any difference between these
functions.

std::tr1::array - What's the difference between max_size and size?

Thank you.

-Sarath

SG

unread,
Aug 17, 2009, 10:22:17 AM8/17/09
to

Good question. It's not explained in the draft
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf

But max_size probably returns the maximum number of elements that can
be stored in this container. Since array is a fixed-size container I
would guess that the resulf of array<T,N>::max_size() equals
array<T,N>::size().

Cheers!
SG

Pete Becker

unread,
Aug 17, 2009, 10:51:35 AM8/17/09
to
Sarath wrote:
> From the documentaiton, I could not find any difference between these
> functions.
>
> std::tr1::array - What's the difference between max_size and size?
>

STL containers in general provide both member functions. size() tells
you how many elements there are currently in the container, and
max_size() gives you an estimate of the maximum number of elements that
you could put into the container.

For array, both values are the same.

--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of
"The Standard C++ Library Extensions: a Tutorial and Reference"
(www.petebecker.com/tr1book)

Knockr

unread,
Aug 19, 2009, 4:46:54 AM8/19/09
to

Thanks Pete and SG

0 new messages