Call different member functions on object sequence with a generic handler function?
Robert M. Münch
robert.muench at saphirion.com
Fri Jun 29 16:44:36 UTC 2018
I hope this is understandable... I have:
class C {
void A();
void B();
void C();
}
I'm iterating over a set of objects of class C like:
foreach(obj; my_selected_objs){
...
}
The iteration and code before/afterwards always looks the same, I need
this iteration for many of the memember functions like C.A() and C.B(),
etc.
foreach(obj; my_selected_objs){
...
obj.A|B|C()
...
}
So, how can I write a generic handler that does the iteration, where I
can specify which member function to call?
void do_A() {
handler(C.A()); ???
}
void do_B() {
handler(C.B()); ???
}
handler(???){
foreach(obj: my_selected_objs){
???
}
}
Viele Grüsse.
--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster
More information about the Digitalmars-d-learn
mailing list