digitalmars.D - Array creating expression
- bernhard at dragoneyrie dot de (8/8) Jul 10 2004 I think, it would be useful to create an array as expression.
- Andy Friesen (15/24) Jul 10 2004 This should tide you over:
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
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