isCallable is not an expression
    Ali Çehreli via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Wed Sep 24 10:59:04 PDT 2014
    
    
  
On 09/24/2014 01:11 AM, andre wrote:
 > template MyTemplate()
 > {
 >      import std.traits : isSomeFunction, functionAttributes,
 > FunctionAttribute, ReturnType;
 >
 >      string[] getPropertyNames()
1) You need a "this template parameter":
     string[] getPropertyNames(this MyType)()
2) Now, replace all typeof(this) expressions with MyType below.
 >      /*string[] getPropertyDuplicate()
3) Same here:
     string[] getPropertyDuplicate(this MyType)()
And it works! :)
class A {
     mixin MyTemplate;
     @property int zzz()
     {
         return 42;
     }
}
void main() {
     auto a = new A();
     import std.string;
     assert(a.getPropertyNames() == [ "zzz" ]);
     assert(a.getPropertyDuplicate() == [ "zzz" ]);
}
Ali
    
    
More information about the Digitalmars-d-learn
mailing list