@nogc with opApply
Alex
sascha.orlov at gmail.com
Sun Aug 12 12:23:19 UTC 2018
On Sunday, 12 August 2018 at 01:39:21 UTC, ag0aep6g wrote:
> On 08/11/2018 12:00 PM, Alex wrote:
>> [...]
> [...]
>> [...]
> [...]
>> [...]
> [...]
>> [...]
>
> You can provide to overloads: one with @nogc, one without it.
> To keep it somewhat DRY, you can let them forward to a template
> implementation:
>
> int opApply(scope int delegate(ref uint) operations)
> {
> return opApplyImpl(operations);
> }
> int opApply(scope int delegate(ref uint) @nogc operations)
> @nogc
> {
> return opApplyImpl(operations);
> }
> int opApplyImpl(O)(O operations)
> {
> /* ... implementation here ... */
> }
Ah... that's nice...
Thanks!
More information about the Digitalmars-d-learn
mailing list