🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Nico Josuttis Tue, 02 Apr 1996 13:32
reserve() and capacity()
#3888
Author: Nico Josuttis
Date: Tue, 02 Apr 1996 13:32
44 lines
2590 bytes
Two "container" have reserve() and capacity():
 string and vector.
For both first a simple hint:
The january draft says, that 
    It is guaranteed that no
    reallocation takes place during the  insertions  that  happen  after
    reserve()  takes  place  till  the  time when the size of the vector/string

    reaches the size specified by reserve().
First "reaching" the size should also guarantee that no reallocation takes
place. I think "exceeds" would be the correct naming here.

But I have deeper questions:
For vectors for every member function it is documented how it unvalidates
iterators and references.
Following that I would guess that
 a) vector capacity in general can't shrink
 b) iterators stay valid even if following elements get destroyed
On the other hand the standard says that
 a) no reallocation takes place during the  INSERTIONS ...
 b) The reference returned by the non-const version is invalid after any
    subsequent call to c_str(), data(), or any non-const member function
    for the object. 
    (only for string, the vector version is missing)

So my questions are:
 - What is right for vector and string?
 - How long stay iterators and references valid for both?
 - May the capacity() shrink for both?

Thanks in advance
--------
Nico                             address: BREDEX GmbH
email:   nico@bredex.de                   Nicolai Josuttis
                                          Fallersleber-Tor-Wall 23
phone:   +49 531 24330-0                  D-38100 Braunschweig
fax:     +49 531 24330-99                 Germany
--------
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads