isCallable fails

frame frame86 at live.com
Wed Jan 20 04:43:12 UTC 2021


On Wednesday, 20 January 2021 at 01:07:15 UTC, Ali Çehreli wrote:
> 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

ok, sorry my bad - I have just shortend the code, the first part 
is from a template indeed:

void something(T, string property)() {

   // in THIS context is T a class
   // property = "data"

   alias S = __traits(getMember, T, property);

   // typeof(S) = foo!bar

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

   // ...

}

And struct of course, has another identfier:

struct foo(T) {
   T get() {
         static if (is(T : bar)) {
             if (value is null) {
                 value = fun!T;
             }
         }
         return value;
     }
}

There are other properties with foo!T and they are working as 
expected. The problem occurs if I want to assign value = fun!T.









More information about the Digitalmars-d-learn mailing list