Boost logo

Boost :

Subject: Re: [boost] [utility] new auto_buffer class --- RFC
From: Peter Dimov (pdimov_at_[hidden])
Date: 2009-03-02 13:35:13


Thorsten Ottosen:
> I guess your case above should be implemented as
>
> for # of rows
> v.clear();
> v.resize( n );

    v.reserve( n );

> for each element read e
> v.push_back_unchecked(e)
> process( v.begin(), v.end() )
...

> But as the example above shows, we do not need a growing push_back()
> here.

Yes, this second example was supposed to show that we sometimes need to
alter the capacity. If you want it to argue for push_back, change the file
format so that the rows are terminated with a sentinel instead of prefixed
with n. :-)


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk