2
struct Foo{
int _a;
this(int a){ _a = a; }
int opCall(int b){ return b * b; }
}
Foo f;
int rt = f(33); //Error: cannot implicitly convert expression ((Foo __ctmp1294 = 0;
//, __ctmp1294).this(33)) of type Foo to int
TDPLまたはウェブサイトのopCall
に関する十分な情報が見つかりません。opCallを正しく使うには?
this()
とopCall()
の両方が必要ですが、this()
が存在する場合、上記のコードは機能しません。私はコンストラクタを取り除かなければならないのですか?