How to partially apply member functions?
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jun 30 11:15:20 PDT 2017
On 06/30/2017 01:43 AM, ct wrote:
> entry_.addOnNextMatch(partial!(&this.OnNextPreviousMatch, true));
Just to note, member function pointers are delegates in D, which
combines the 'this' pointer of the object and a context pointer. Since
the object is available at run time, such a delegate cannot be used as a
template parameter.
partial is designed to work with free standing functions. It uses the
second template argument as the first parameter to the function. So,
there is no consideration for member function calls. Perhaps partial can
be improved to handle that case but I don't know whether the 'this'
pointer can be added to the delegate easily or at all.
Ali
More information about the Digitalmars-d-learn
mailing list