Implementing Template Restrictions in Different Way
    monarch_dodra via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Tue Sep  2 05:13:59 PDT 2014
    
    
  
On Tuesday, 2 September 2014 at 11:41:51 UTC, Nordlöw wrote:
> 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.
In that case, I'm not sure what you mean by "fastest" in the 
context of "constraints", which are compile-time.
>> 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?
I think so yes. That's the "R/E" version though. Is the "R/R" 
version also subject to this issue?
    
    
More information about the Digitalmars-d-learn
mailing list