This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Why does the [] operator in vector behave as it does?


--- Luke Dickens <lwd03@doc.ic.ac.uk> wrote:
> Thank you Ted.
> 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.
> 
In my code, they are pervasive as I use them from the
start, as planned during the design phase of a
project.

That said, how easy or difficult it is to refactor
your code to use this idiom depends on how much code
there is, and how you use the objects.  But, I have
seen it take just a few hours on a project having
500,000 lines of code.  The kinds of issues, if the
existing code takes objects of type T, range from
overloading your functions that work on them to take
smart pointers to type T, that the correct operator
'->' vs '.' is used to invoke member functions, the
right function objects are used, &c.  Everything you
do with these objects would need to be recast as
working with smart pointers instead.  But doing it all
is relatively easy if you have a decent development
IDE and you are organized.  You DO have design
documents that specify what you do to what, and where
the relevant code is, right?  If so, that makes it
trivial to construct a to do list that can serve to
check off all the changes you'd need to make to use
smart pointers instead of the objects of type T
themselves.  That kind of organization makes most
things go much faster.

HTH

Ted


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]