Boost logo

Boost :

From: Larry Evans (cppljevans_at_[hidden])
Date: 2006-01-11 09:59:57


On 01/11/2006 08:27 AM, Achilleas Margaritis wrote:
[snip]
> -------------------------------------------------------
> Alternative 1 - using gc_ptr<T> for global, stack and member pointers.
>
> It is possible to use the gc_ptr class for global, stack and member
> pointers. The class would have to check if it belongs in the last-known
> created object by checking its address against the address of the last
> created object. If the pointer falls within the memory area of the last
> created object, then it is a member pointer, otherwise it is a global/stack
> pointer. Example code:
>
> template < class T > class gc_ptr {
> public:
> gc_ptr() {
> if this not within last created object then {

This test, IIUC, requires access to a global object
(pointer to last created object or something similar).
Wouldn't this then require synchronization between
threads; hence, cause a big slowdown for each gc_ptr
creation?

> pointer stack->push(this);
> }
> }
> };
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk