Exceeding container::max_size()?

Discussion in 'C++' started by Kevin Goodsell, Apr 3, 2004.

  1. I was unable to locate the answer to this question in the (draft)
    Standard or in The C++ Standard Library (Josuttis). What should occur
    when one attempts to increase the size of a container beyond its max_size()?

    The closest thing I found to an answer was that the reserve() member of
    std::basic_string and std::vector and the resize() member of
    std::basic_string throw std::length_error if the new size exceeds
    max_size(). This seems likely to apply to all "growing" operations of
    all containers, and is consistent with the description of
    std::length_error, but I can't find anything that explicitly states this.

    Thanks.

    -Kevin
    --
    My email address is valid, but changes periodically.
    To contact me please use the address from a recent posting.
     
    Kevin Goodsell, Apr 3, 2004
    #1
    1. Advertising

  2. "Kevin Goodsell" <> wrote...
    > I was unable to locate the answer to this question in the (draft)
    > Standard or in The C++ Standard Library (Josuttis). What should occur
    > when one attempts to increase the size of a container beyond its

    max_size()?

    AFAIUI, 'max_size' is not a requirement but rather a statement of fact.
    You should never be able to create a container of that size -- you will
    most likely run out of memory first.

    > The closest thing I found to an answer was that the reserve() member of
    > std::basic_string and std::vector and the resize() member of
    > std::basic_string throw std::length_error if the new size exceeds
    > max_size(). This seems likely to apply to all "growing" operations of
    > all containers, and is consistent with the description of
    > std::length_error, but I can't find anything that explicitly states this.


    23.2.4.2/4 for 'std::vector'. 21.3.3/6 for 'std::basic_string'.

    V
     
    Victor Bazarov, Apr 4, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. alexey_m
    Replies:
    2
    Views:
    338
    =?ISO-8859-1?Q?Stefan_N=E4we?=
    Dec 22, 2005
  2. t

    max_size()

    t, Oct 2, 2007, in forum: C++
    Replies:
    4
    Views:
    420
    James Kanze
    Oct 3, 2007
  3. Sarath
    Replies:
    2
    Views:
    609
    Knockr
    Aug 19, 2009
  4. Juha Nieminen
    Replies:
    0
    Views:
    328
    Juha Nieminen
    Feb 10, 2011
  5. Great Deals
    Replies:
    1
    Views:
    238
    laura fairhead
    Oct 1, 2003
Loading...

Share This Page