isCallable fails

Ali Çehreli acehreli at yahoo.com
Wed Jan 20 01:07:15 UTC 2021


I may know the answer but I can't be sure because you don't provide code 
that reproduces the issue.

I am trying to write code below according to your description but it's 
really tough. Can you reproduce the issue please.

// T         = some class
// T is not a good name because it is usually used template parameters
class T {
   static U!int data = 42;
}

// S         = "data" (data is member of T)
auto S = T.data;
// typeof(S) = some struct U!X, not void

// WAIT! Another S? You're asking for trouble. :D
alias S = __traits(getMember, T, property);

static if (isCallable!S) {
     // some other magic
}

// WAIT! So, this is U?
struct U(T) {
   T get() {
         static if (is(T : X)) {
             if (value is null) {
                 // load value
             }
         }
         return value;
   }

   T value;
   alias get this;
}

void main() {
}

Ali



More information about the Digitalmars-d-learn mailing list