Nothrow front() when not empty()

2016-01-06 Thread Nordlöw via Digitalmars-d-learn
At https://github.com/D-Programming-Language/phobos/pull/3752 it would be nice if return !haystack.empty && haystack.front.unaryFun!pred was made nothrow. Is this possible somehow?

Re: Nothrow front() when not empty()

2016-01-06 Thread anonymous via Digitalmars-d-learn
On 06.01.2016 14:52, Nordlöw wrote: At https://github.com/D-Programming-Language/phobos/pull/3752 it would be nice if return !haystack.empty && haystack.front.unaryFun!pred was made nothrow. Is this possible somehow? try return !haystack.empty && pred(haystack.front); catch

Re: Nothrow front() when not empty()

2016-01-06 Thread Alex Parrill via Digitalmars-d-learn
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));