digitalmars.D - Calling an alias for a Class method in another scope
- d coder (22/22) May 31 2012 Greetings
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); }
May 31 2012