From d24b738cccf7e6ec09025e33e9732b59eaab76ab Mon Sep 17 00:00:00 2001 From: Matt Kline Date: Fri, 17 Apr 2015 00:32:05 -0700 Subject: [PATCH] Clean up Unique alias this --- std/typecons.d | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/std/typecons.d b/std/typecons.d index c0d350cf7..b5851e63d 100644 --- a/std/typecons.d +++ b/std/typecons.d @@ -159,8 +159,7 @@ else bool opCast(T : bool)() const { return !empty; } /** - Allows you to dereference the underlying $(D RefT) - and treat it like a $(D RefT) in other ways (such as comparing to null) + Allows you to reference the underlying $(D RefT) */ alias get this; @@ -265,6 +264,7 @@ unittest auto i = unique!int(25); assert(i.get() == 25); + assert(i == 25); // opAssign still kicks in, preventing this from compiling: // i = null; @@ -304,7 +304,7 @@ unittest void consume(Unique!S u2) { - assert(u2.i == 7); + assert(u2.i == 8); // Resource automatically deleted here } @@ -314,7 +314,9 @@ unittest increment(u1); assert(u1.i == 6); correctIncrement(u1.get()); - assert(u1.i == 7); + // yay alias this + correctIncrement(u1); + assert(u1.i == 8); // consume(u1); // Error: u1 is not copyable