This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: C++ and garbage collection
* Enrico Weigelt:
>> GCC includes a tr1::shared_ptr so there's no extra dependency if you
>> are only planning to use g++, and std::shared_ptr is part of C++0x.
>
> How does that one actually work and what do I have to do to use it ?
What's the oldest GCC version you're targeting?
Modern GCC has std::unique_ptr (zero-overhead pointer wrapper with
RAII semantics), std::shared_ptr and std::make_shared (avoiding a
separate allocation using operator new). This should work after some
adjustments, as long as your data structures are acyclic. You just
have to avoid taking short-cuts to optimize things, using references
and plain pointers instead of the std:: wrappers. In this regard,
Boehm GC is hard to beat.