July 10, 2004 Array creating expression | ||||
---|---|---|---|---|
| ||||
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; } |
July 10, 2004 Re: Array creating expression | ||||
---|---|---|---|---|
| ||||
Posted in reply to bernhard at dragoneyrie dot de | 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
|
Copyright © 1999-2021 by the D Language Foundation