Unable to pass shared class method as delegate
d coder
dlang.coder at gmail.com
Sun Apr 24 07:40:02 PDT 2011
Greetings
I am facing problem passing a shared class method as an argument to a
function. Look at the following minimized code snippet.
class Foo {
shared // compiles when commented out
void bar() {}
}
void frop(void delegate() dg) {
}
void main() {
shared Foo foo = new shared(Foo);
frop(&foo.bar);
}
I get the following errors (using dmd 2.052)
dg.d(11): Error: function dg.frop (void delegate() dg) is not callable using
argument types (void delegate() shared)
dg.d(11): Error: cannot implicitly convert expression (&foo.bar) of type
void delegate() shared to void delegate()
Please suggest a valid signature for the function frop, so that it can take
shared delegates.
Regards
- Puneet
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20110424/8fdb6b00/attachment.html>
More information about the Digitalmars-d-learn
mailing list