Of Bounties and Mercenaries
Stephan T. Lavavej
stl@caltech.edu
Tue Apr 6 08:27:00 GMT 2004
[Alexandre Oliva]
> It doesn't take care of cycles, though, and they're quite
> pervasive in GCC.
Cycles are the standard objection to my argument.
It also completely misses the point. I advocate using shared_ptr (a
reference counted pointer) to hold noncopyable resource managers - that
doesn't introduce cycles.
If you have a data structure which has cycles, then you should encapsulate
it. For example, std::list is a doubly linked list and hence has cycles of
pointers inside of it. But the user of std::list doesn't have to know or
care about that.
Manual memory management is a reasonable thing to do, as long as it stays
confined to the constructor, destructor, and methods of a single class that
needs to do something exotic. (Of course, the same class can use vectors
and whatnot to do mundane things.)
Stephan T. Lavavej
http://nuwen.net
More information about the Gcc
mailing list