opApply and attributes
laszloszeremi at outlook.com
Tue Jul 7 20:20:54 UTC 2020
On Tuesday, 7 July 2020 at 13:33:41 UTC, Paul Backus wrote:
> You can make opApply a template:
> int opApply(Dg)(Dg dg)
> if (is(Dg : scope int delegate(ref E)))
> // etc.
> Because `scope int delegate(ref E) @safe` implicitly converts
> to `scope int delegate(ref E)`, this version will accept both
> @safe and non- at safe delegates. (And likewise for the other
> function attributes.)
Unfortunately this doesn't really work, even with explicitly
defined foreach arguments.
More information about the Digitalmars-d-learn