Boost logo

Boost :

From: rwgk (rwgk_at_[hidden])
Date: 2002-03-06 14:19:42

--- In boost_at_y..., "Stewart, Robert" <stewart_at_s...> wrote:
> > Unfortunately the reserve() solution eventually requires
> > use of push_back(), which is also slow.
> If you use push_back() following reserve(), there is no performance
> The push_back()'ed object is copied into the next element. If you
> the size allocated with reserve(), then push_back() will cause
> and copying, so be sure to choose the right size when calling

Here is an example push_back() implementation:

      void push_back(const ElementType& x) {
        if (size() < capacity()) {
          new (end()) ElementType(x);
        else {
          m_insert_overflow(end(), size_type(1), x, true);

I doubt that the optimizer can entirely remove the
overhead associated with incrementing the size,
and it can certainly not remove the "if" statement.


P.S.: Sorry for accidentally posting the partial message.

Boost list run by bdawes at, gregod at, cpdaniel at, john at