Member function pointers
Steven Schveighoffer
schveiguy at yahoo.com
Mon Jun 10 09:52:33 PDT 2013
On Mon, 10 Jun 2013 12:45:12 -0400, Jacob Carlborg <doob at me.com> wrote:
> On 2013-06-10 18:38, dennis luehring wrote:
>
>> maybe he just don't need one to handle the this ptr because he wants to
>> call several/hundrets of member-functions?
>
> How does he call a pointer to a member function without the "this"
> pointer?
Like this:
void callRandomMember(C[] objs, memberPointerToCMethod p)
{
objs[random(0, objs.length)].p();
}
Essentially, you bind at call time to form a delegate. But the member
function pointer's 'this' must be strongly typed.
-Steve
More information about the Digitalmars-d
mailing list