Signals and Slots in D

xs0 xs0 at xs0.com
Fri Sep 29 08:35:17 PDT 2006


Lionello Lunesu wrote:

> I think my other reply addresses the wrong issue, but I still think we 
> can use RAII + c-heap. We just need 1 extra indirection:
> 
> class Test {
>     ~this() { printf("~Test\n"); }
> }
> 
> class WeakPtr(T) {
>     private T* _ptr;
>     this() { _ptr = cast(T*)std.c.stdlib.malloc(_ptr.sizeof); }
>     ~this() { printf("~WeakPtr\n"); std.c.stdlib.free(_ptr); }
>     T ptr() { return *_ptr; }
>     T ptr(T p) { return *_ptr = p; }
> }

But how can you tell if _ptr is valid or not? If you can't, it's pretty 
useless, as you can never safely dereference it...


xs0



More information about the Digitalmars-d mailing list