Call different member functions on object sequence with a generic handler function?

Jerry labuurii at gmail.com
Sat Jun 30 22:53:47 UTC 2018


On Friday, 29 June 2018 at 20:23:47 UTC, Timoses wrote:
> void handler(alias func, T)(T[] ts) {
>     ....
> }

Btw this is pretty much std.algorithm.each

import std.algorithm;

void main() {
   auto cs = [ new C(), new C() ];
   cs.each!(o => o.A());
}

https://dlang.org/phobos/std_algorithm_iteration.html#.each




More information about the Digitalmars-d-learn mailing list