xxxxxxxxxx
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
}
// ...
}
struct foo(T) {
T get() {
static if (is(T : bar)) {
if (value is null) {
value = fun!T("id", 123);
}
}
return value;
}
T value;
alias get this;
}
TDobj fun(TDobj, T)(string propertyName, T needle) if (is(TDobj : bar)) {
TDobj[] list = loadAllMatched!TDobj(propertyName, needle, 1);
return list.length > 0 ? list[0] : null;
}