Need size of rightmost array, not type...

Max Samukha samukha at voliacable.com
Thu Feb 22 00:44:14 PST 2007


On Wed, 21 Feb 2007 23:59:21 -0300, Ary Manzana <ary at esperanto.org.ar>
wrote:

>This compiles fine:
>
>----------------------------------------
>template Foo() {
>	const int Foo = 3;
>}
>
>void one() {
>	int x = Foo!();
>	char[] buf = new char[x];
>}
>----------------------------------------
>
>However this:
>
>----------------------------------------
>template Foo() {
>	const int Foo = 3;
>}
>
>void two() {
>	char[] buf = new char[Foo!()];
>}
>----------------------------------------
>
>main.d(6): need size of rightmost array, not type Foo!()
>
>Why?

Seems to be a bug. If your array is not big, you might consider using
a static array as the size is known at compile time.

char[Foo!()] buf; works
 



More information about the Digitalmars-d mailing list