Boost logo

Boost :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-05-06 21:34:19


shiwei xu wrote:
> typedef void (*DestructorType)(void* data);
> concept GCAllocator
> {
> // Allocate memory without given a cleanup function
> void* allocate(size_t cb);
> // Allocate memory with a cleanup function
> void* allocate(size_t cb, DestructorType fn);
> // Cleanup and deallocate all allocated memory by this GC Allocator
> void clear();
> // Swap two GCAllocator instances
> void swap(GCAllocator& o);
> };

I have a question about exception safety. Suppose that
I specify a destructor when I allocate memory, and then,
the constructor of the object throws. Is there any way
to prevent the destructor from being called, given this interface?
Otherwise, the destructor might end up being called on
an object that was never initialized.

In Christ,
Steven Watanabe

Boost list run by bdawes at, gregod at, cpdaniel at, john at