isCallable fails
frame
frame86 at live.com
Tue Jan 19 22:56:00 UTC 2021
What could cause the following error?
Error: expression isCallable!(data) of type void does not have a
boolean value
Problematic lines are:
// T = some class
// S = "data" (data is member of T)
// typeof(S) = some struct U!X, not void
alias S = __traits(getMember, T, property);
static if (isCallable!S) {
// some other magic
}
So, struct U has an "alias this", not causing any problems except
if it calls the getter on type X:
struct U(T) {
T get() {
static if (is(T : X)) {
if (value is null) {
// load value
}
}
return value;
}
T value;
alias get this;
}
I do not understand why this can affect isCallable as it does
nothing special. It also compiles if I remove the loading "static
if" switch.
More information about the Digitalmars-d-learn
mailing list