diff options
| author | Mike Wey | 2011-01-29 23:16:07 +0100 |
|---|---|---|
| committer | Mike Wey | 2011-01-29 23:16:07 +0100 |
| commit | 7e793c9571f88ba422850e780e7cafff2cd3f1b2 (patch) | |
| tree | 6a37d07b76bc8b6f0e0145bc3100734f200fb4cb /dmagick/Utils.d | |
| parent | 593d9e0b18a4d935ab01024f4a0150825a3630e8 (diff) | |
Simplyfy the Refcounted template a little
Diffstat (limited to 'dmagick/Utils.d')
| -rw-r--r-- | dmagick/Utils.d | 6 |
1 files changed, 3 insertions, 3 deletions
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 ); |
