Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Fix issue 8411 - add opCast!bool support for Duration.
Browse files Browse the repository at this point in the history
  • Loading branch information
schveiguy committed Mar 16, 2017
1 parent f6ab1e2 commit 1caa1fc
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/core/time.d
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,21 @@ public:
}
}

/++
Returns `true` if this duration is non-zero.
+/
bool opCast(T : bool)() const nothrow @nogc
{
return _hnsecs != 0;
}

unittest
{
auto d = 10.minutes;
assert(d);
assert(!(d - d));
assert(d + d);
}

//Temporary hack until bug http://d.puremagic.com/issues/show_bug.cgi?id=5747 is fixed.
Duration opCast(T)() const nothrow @nogc
Expand Down

0 comments on commit 1caa1fc

Please sign in to comment.