Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/core/time.d
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,22 @@ public:
}
}

/++
Allow Duration to be used as a boolean.
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