possible improvement to if statements?

Steven Schveighoffer schveiguy at gmail.com
Sun Apr 26 21:26:31 UTC 2020


On 4/26/20 5:06 PM, Sebastiaan Koppe wrote:
> On Sunday, 26 April 2020 at 20:41:47 UTC, Steven Schveighoffer wrote:
>> Does anyone have a workable way this kind of thing could be added to D?
>>
> 
> Did you consider this?

No I haven't, that's at least as good as the foreach version (though 
having a simple ref is nicer than having a wrapper type). Is this 
located anywhere on code.dlang.org or in phobos?

But there is one issue -- what if P defines opCast(bool)?

Still it's almost good enough, and probably better than what I wrote.

I would still like an improvement to this pattern that fits what I want 
to do -- essentially, if this exists, give me a reference to it, and let 
me use it.

-Steve


More information about the Digitalmars-d mailing list