[comp.lang.c++] Emulate elementsPerform:with: metho

johnson@p.cs.uiuc.edu (10/10/88)

>I would like to send a message to each element on a list of objects.
>I'd also like the message to be an argument that I give to the routine
>that does the sending.  This emulates the action of the Objective-C
>elementsPerform:with: method.  So far, I can't see a way to do this
>using, for instance, pointers to member functions.

Assumeing that you have a list of objects of classes that are subclasses
of T, you can pass in a function on objects of T that sends the message.
The routine that does the sending will then evaluate the function for
each element of the list.