class Test{ template test(){ const int test=1; } } void main(){ assert(Test.test!()==1);//ok assert((new Test).test!()==1);//failed }
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 d-bugmail@puremagic.com schrieb am 2006年11月19日: > http://d.puremagic.com/issues/show_bug.cgi?id=571 > class Test{ > template test(){ > const int test=1; > } > } > > void main(){ > assert(Test.test!()==1);//ok > assert((new Test).test!()==1);//failed > } Added to DStress as http://dstress.kuehne.cn/run/t/template_47_A.d http://dstress.kuehne.cn/run/t/template_47_B.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFFaEqHLK5blCcjpWoRAgCJAJ9dZUpUeaSP0QBXBufU/RlYeYqjAwCglpP4 IY/UQZYAOBYmlU3lVwDvuCE= =pw18 -----END PGP SIGNATURE-----
This is invalid code in D 2.0, as templates cannot be used to add fields to a class.
Updated test case for D2: class Test { template test(){ enum int test = 1; // replace with const for D1 } } void main(){ printf("%d", (new Test()).test!()); }
Fixed dmd 1.032 and 2.016
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル