From 7e793c9571f88ba422850e780e7cafff2cd3f1b2 Mon Sep 17 00:00:00 2001 From: Mike Wey Date: Sat, 29 Jan 2011 23:16:07 +0100 Subject: Simplyfy the Refcounted template a little --- dmagick/Utils.d | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'dmagick/Utils.d') diff --git a/dmagick/Utils.d b/dmagick/Utils.d index 2550c40..e8cef21 100644 --- a/dmagick/Utils.d +++ b/dmagick/Utils.d @@ -66,7 +66,7 @@ real degreesToRadians(real deg) } struct RefCounted(alias pred, T) - if ( !is(T == class) && is(typeof(pred(cast(T*)null)) == void) ) + if ( !is(T == class) && is(typeof(pred(cast(T*)null)) == T*) ) { T* payload; @@ -96,7 +96,7 @@ struct RefCounted(alias pred, T) (*refcount)--; if ( *refcount == 0 ) - pred(payload); + payload = pred(payload); } @property size_t refCount() @@ -110,7 +110,7 @@ unittest int x = 10; int y = 20; - alias RefCounted!( (void* t){ x = 20; }, int ) IntRef; + alias RefCounted!( (int* t){ x = 20; return t; }, int ) IntRef; auto a = IntRef(&x); assert( a.refCount == 1 ); -- cgit v1.2.3