Thread overview | |||||
---|---|---|---|---|---|
|
October 29, 2004 array initialization in template | ||||
---|---|---|---|---|
| ||||
dmd 1.04, winXP looks like the initialization of an array in a class in a template is missing... try this code. <code> template Foo(T, int L) { T[L] arr; class Bar { T[L] arr; } } unittest { alias Foo!(int, 100) foo; foreach (int x; foo.arr) assert(x == int.init); // initialized, no problem foo.Bar bar = new foo.Bar(); foreach (int x; bar.arr) assert(x == int.init); // not initialized, fails } </code> tetsuya |
October 31, 2004 Re: array initialization in template | ||||
---|---|---|---|---|
| ||||
Posted in reply to tetsuya | added to dstress as svn://svn.kuehne.cn/dstress/run/array_initialization_03.d . It should work, and in fact does so on Linux. Either this is a Windows spezific problem or you code snipplet is incomplete. Thomas tetsuya schrieb: > dmd 1.04, winXP > > looks like the initialization of an array in a class > in a template is missing... > > try this code. > > <code> > template Foo(T, int L) > { > T[L] arr; > class Bar { T[L] arr; } > } > > unittest > { > alias Foo!(int, 100) foo; > > foreach (int x; foo.arr) > assert(x == int.init); // initialized, no problem > > foo.Bar bar = new foo.Bar(); > > foreach (int x; bar.arr) > assert(x == int.init); // not initialized, fails > } > </code> > > tetsuya |
November 01, 2004 Re: array initialization in template | ||||
---|---|---|---|---|
| ||||
Posted in reply to Thomas Kuehne | then it must be a windows specific problem, anyway.. thanks for the report In article <cm3l21$1peu$4@digitaldaemon.com>, Thomas Kuehne says... > >added to dstress as svn://svn.kuehne.cn/dstress/run/array_initialization_03.d . > >It should work, and in fact does so on Linux. >Either this is a Windows spezific problem or you code snipplet is incomplete. > >Thomas > >tetsuya schrieb: >> dmd 1.04, winXP >> >> looks like the initialization of an array in a class >> in a template is missing... >> >> try this code. >> >> <code> >> template Foo(T, int L) >> { >> T[L] arr; >> class Bar { T[L] arr; } >> } >> >> unittest >> { >> alias Foo!(int, 100) foo; >> >> foreach (int x; foo.arr) >> assert(x == int.init); // initialized, no problem >> >> foo.Bar bar = new foo.Bar(); >> >> foreach (int x; bar.arr) >> assert(x == int.init); // not initialized, fails >> } >> </code> >> >> tetsuya > > > |
Copyright © 1999-2021 by the D Language Foundation