Calling an alias for a Class method in another scope
d coder
dlang.coder at gmail.com
Thu May 31 17:50:02 PDT 2012
Greetings
Kindly make me understand this. I have been trying to call an alias for a
class method from another scope. I keep getting an error saying that I need
"this" to call a method. Why will not "this" pointer be available when I am
passing the method symbol along with an object of the class? Is there
another way of doing what I am trying to achieve. I have pasted a sample
code below here.
Regards
- Puneet
void callfoo(alias F, T) (T t) {
void foo() {
F(); // Error: need 'this' to access member foo
t.F(); // Error: undefined identifier 'F'
}
}
class Foo {
void foo() {}
}
void main() {
Foo f = new Foo();
callfoo!(f.foo)(f);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120601/d1a28ad9/attachment.html>
More information about the Digitalmars-d
mailing list