Date: Sun, 15 May 2005 12:00:55 +0100 From: Jean-Fran?ois Brouillet
Subject: [Boost-users] Re: shared_ptr, intrusive_ptr ... To: boost-users@lists.boost.org Message-ID: Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed On 2005-05-15 00:49:54 +0100, "Peter Dimov"
said: Anyway, here's my revised snippet that satisfies all my criteria: -- JFB
#include <iostream>
#include
struct ObjectStruct { int refCount ;
ObjectStruct() : refCount(0) { std::cout << std::hex << (int) this << " - I'm born" << std::endl ; }
void refer() { ++refCount ; } void unrefer() { if (--refCount == 0) delete this ; }
virtual ~ObjectStruct() { std::cout << std::hex << (int) this << " - I'm gone" << std::endl ; } } ;
void intrusive_ptr_add_ref(ObjectStruct * p) { p->refer() ; } void intrusive_ptr_release(ObjectStruct * p) { p->unrefer() ; }
Are you going to make it thread-safe (or is that something you just left out of the example?)?