Re: C++ and garbage collection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* 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.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux