Implementing Template Restrictions in Different Way
"Nordlöw" via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Sep 2 04:41:48 PDT 2014
On Tuesday, 2 September 2014 at 10:22:49 UTC, monarch_dodra wrote:
>> the fastest way to do this?
>
> Are you talking about constraints, or implementation of
> safeSkipOver?
The constraint.
> Hum... Are you writing this function because skipOver will
> actually fail? AFAIK, it shouldn't. We should fix skipOver...
Yes, I'm writing this wrapper because call to r.front in
bool skipOver(alias pred = "a == b", R, E)(ref R r, E e)
if (is(typeof(binaryFun!pred(r.front, e))))
{
if (!binaryFun!pred(r.front, e))
return false;
r.popFront();
return true;
}
fails when r is empty.
It believe it should be
if (r.empty || !binaryFun!pred(r.front, e))
right? Should I do a PR?
More information about the Digitalmars-d-learn
mailing list