Nothrow front() when not empty()

Alex Parrill via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jan 6 11:45:47 PST 2016


On Wednesday, 6 January 2016 at 14:17:51 UTC, anonymous wrote:
> try return !haystack.empty && pred(haystack.front);

Might want to use std.exception.assumeWontThrow instead

     return assumeWontThrow(!haystack.empty && 
pred(haystack.front));

http://dlang.org/phobos/std_exception.html#.assumeWontThrow


More information about the Digitalmars-d-learn mailing list