diff options
| -rw-r--r-- | dmagick/Image.d | 7 | ||||
| -rw-r--r-- | dmagick/Utils.d | 6 |
2 files changed, 4 insertions, 9 deletions
diff --git a/dmagick/Image.d b/dmagick/Image.d index 2b66aaa..3df6e00 100644 --- a/dmagick/Image.d +++ b/dmagick/Image.d @@ -19,12 +19,7 @@ import dmagick.c.image; class Image { alias dmagick.c.image.Image MagickCoreImage; - //We can't reduce the function literal further, becase that generates an error. - alias RefCounted!( function(MagickCoreImage* img) - { - img = DestroyImage(img); - }, MagickCoreImage ) ImageRef; - + alias RefCounted!( DestroyImage, MagickCoreImage ) ImageRef; ImageRef imageRef; Options options; 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 ); |
