www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Array creating expression

reply bernhard at dragoneyrie dot de <bernhard_member pathlink.com> writes:
I think, it would be useful to create an array as expression.
It could look like:

void blubb(float f) {
float a[];
// ...
a = new float[](f,-f,3*f);
// doing anything with a;
}
Jul 10 2004
parent Andy Friesen <andy ikagames.com> writes:
bernhard at dragoneyrie dot de wrote:
 I think, it would be useful to create an array as expression.
 It could look like:
 
 void blubb(float f) {
 float a[];
 // ...
 a = new float[](f,-f,3*f);
 // doing anything with a;
 }

This should tide you over: import std.stdarg; template MakeArray(T) { T[] MakeArray(...) { T[] result; result.length = _arguments.length; foreach (int i, TypeInfo ti; _arguments) { assert(typeid(T) is ti); // FIXME: breaks under inheritance result[i] = va_arg!(T)(_argptr); } return result; } } -- andy
Jul 10 2004