From 71e54c199c7de8ed6b63735eebb0ed5fe6937972 Mon Sep 17 00:00:00 2001 From: k-hara Date: Mon, 19 Nov 2012 12:58:47 +0900 Subject: [PATCH] fix Issue 9046 - typeof(T.init) should have the type T hasOverloadedOpAssignWithDuration!T returns true even if T is not a mutable type (e.g. for const Date). But, until now, the type of T.init had been accidentally unqualified by bug 9046. --- std/datetime.d | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/std/datetime.d b/std/datetime.d index 174aadd9b..c8493a5fa 100644 --- a/std/datetime.d +++ b/std/datetime.d @@ -33037,14 +33037,16 @@ unittest +/ template hasOverloadedOpAssignWithDuration(T) { - enum hasOverloadedOpAssignWithDuration = __traits(compiles, T.init += dur!"days"(5)) && - is(typeof(T.init += dur!"days"(5)) == Unqual!T) && - __traits(compiles, T.init -= dur!"days"(5)) && - is(typeof(T.init -= dur!"days"(5)) == Unqual!T) && - __traits(compiles, T.init += TickDuration.from!"hnsecs"(5)) && - is(typeof(T.init += TickDuration.from!"hnsecs"(5)) == Unqual!T) && - __traits(compiles, T.init -= TickDuration.from!"hnsecs"(5)) && - is(typeof(T.init -= TickDuration.from!"hnsecs"(5)) == Unqual!T); + enum hasOverloadedOpAssignWithDuration = is(typeof( + { + auto d = dur!"days"(5); + auto td = TickDuration.from!"hnsecs"(5); + alias U = Unqual!T; + static assert(is(typeof(U.init += d) == U)); + static assert(is(typeof(U.init -= d) == U)); + static assert(is(typeof(U.init += td) == U)); + static assert(is(typeof(U.init -= td) == U)); + })); } unittest