Annotating SortedRange.empty const: Best way to auto-deduce annotations?

SimonN eiderdaus at gmail.com
Wed Sep 2 22:08:56 UTC 2020


On Wednesday, 2 September 2020 at 21:40:59 UTC, Steven 
Schveighoffer wrote:
> What they can do is template the `this` parameter. Then if the 
> underlying range supports calling that way, it will work, 
> otherwise it won't.
>
> using `template this` should be compatible with the existing 
> code I would think.

Thanks! I've never looked much into template this -- at first 
glance, it offers what inout already offers -- but it sounds like 
the right tool for the job. (inout would straightaway disallow 
calls to mutable methods.)

https://dlang.org/spec/template.html#template_this_parameter

I'll experiment with it!

-- Simon


More information about the Digitalmars-d-learn mailing list