D言語 Part14
■ このスレッドは過去ログ倉庫に格納されています
0087デフォルトの名無しさん
2007/07/23(月) 18:47:15// Otsu.new!!(argAlloc)(argCtor)
class Otsu{
template New_(aA...){
static typeof(this) New_(TaC...)(TaC aC){
return new(aA) typeof(this)(aC);
}
}
template New(aA...){
alias New_!(aA) New;
}
int n;
this(int n){ this.n = n; }
}
//任意のクラスに対応できる版
template niw_(T,aA...){
T niw_(TaC...)(TaC aC){
return new(aA) T(aC);
}
}
template niw(T, aA...){
alias niw_!(T,aA) niw;
}
void main(){
printf("%d\n", Otsu.New!()(3).n);
printf("%d\n", niw!(Otsu)(5).n);
}
とかどうだろう
■ このスレッドは過去ログ倉庫に格納されています