On Thursday, 14 March 2013 at 01:34:02 UTC, Marco Leise wrote:
Am Wed, 13 Mar 2013 14:31:42 -0700
schrieb "H. S. Teoh" <[email protected]>:
Why is it bad to have to explicitly list the elements for
static
initialization?
Because of:
struct CompressionData
{
ubyte[4096] x =
[0,0,0 /* ...ad nauseum... */ ,0,0];
}
struct CompressionData
{
ubyte[4096] x; // note this is already [0...0] thanks
// to default init... but still:
this ()
{
x[] = 0;
}
}
--- Or even: ---
import std.range;
struct CompressionData
{
ubyte[4096] x = repeat( 0 )[ 0 .. 4096 ];
}
Assuming repeat()[] is CTFE-able (didn't test).