opCall with struct alias this
Patric Dexheimer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri May 5 06:05:35 PDT 2017
struct Base(T){
static T opCall(Args...)( Args args ){
writeln(args);
writeln("opCall");
T t;
return t;
}
}
struct Data{
Base!Data b;
alias b this;
}
void main()
{
// Expected: opCall of Base!Data, but get error
// auto x = Data(10);
// opCall called. What just happened here?
// never saw anything about init as function.
auto y = Data.init(10);
}
More information about the Digitalmars-d-learn
mailing list