
On 04/06/2006 12:50 AM, Ulrich Eckhardt wrote:
http://boost.org/libs/smart_ptr/intrusive_ptr.html says: "As a general rule, if it isn't obvious whether intrusive_ptr better fits your needs than shared_ptr, try a shared_ptr-based design first." [snip] Another related thing is why is there no complementary class to add a refcounter to an object? Something like
template<typename ObjectType> struct refcount [snip] overhead_referent_vals here:
http://tinyurl.com/k9jhr does this, but with multiple inheritance instead of single. It's designed to be used with auto_overhead ( located in the same directory ), which assures the pointer used in a smart_ptr points into the heap. A closely related discussion is here: http://archives.free.net.ph/message/20060331.100537.108c5fab.en.html However the OP of that thread was just concerned ( AFAICT ) with the thread safety of creating the pointee, but auto_overhead is only concerned with assuring that the argument to the smart_ptr CTOR must be (as enforced by the compiler) from the heap. I have plans to eventually add a source/sink policy to the policy_ptr in the sandbox as proposed in may2005 (but didn't generate much interest). The sketchy proposal is here: http://archives.free.net.ph/message/20050511.215426.101ccded.en.html