This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Why does the [] operator in vector behave as it does?
On Wed, Apr 30, 2008 at 11:32 AM, Luke Dickens <lwd03@doc.ic.ac.uk> wrote:
> I was going to look at smart pointers when I did a code clean-up. I have
> the boost libraries, but don't want to introduce too much new code all at
> once. Are they fairly easy to incorporate into existing code, or is this too
> pervasive a coding paradigm requiring an entire rework.
>
They're very much libraries, not a framework, so you can easily ignore
large parts. (Wave and spirit, for example.)
Also, of particular interest might be the Boost Pointer Containers
library. A boost::ptr_vector<T> is internally a std::vector<T*>, so
it doesn't need copy constructability or assignability of A, with a
helpful interface that calls delete on the pointers before erasing
them from the container and has most of the interface look like a
sequence of T, so you don't need to add extra indirections to
iterators and such.