filling arrays, avoid default init

Thomas Kuehne thomas-dloop at kuehne.cn
Tue Jan 9 14:16:16 PST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lionello Lunesu schrieb am 2007-01-09:
> Lionello Lunesu wrote:
>> Frank Benoit (keinfarbton) wrote:
>>> TypeA[] ta = .... ; // big array with something
>>> TypeB[] tb;
>>> tb.length = ta.length; // (1)
>>> foreach( uint i, TypeA a; ta ){
>>>   tb[i] = ta[i].getB();
>>> }
>>>
>>> (1) how can I avoid the default initialization?
>>>
>>> -- Frank
>> 
>> type[] t = void;
>
> Uhm, sorry. That doesn't seem to prevent the initialization at all...

Can you provide a code sampel?

Tested on Linux:
# import std.stdio;
# 
# typedef int X = 12_34_56_78;
# 
# void main(){
#    X[4] a;
#    X[4] b = void;
# 
#    writefln("a: %s", a);
#    writefln("b: %s", b);
# }

a: [12345678,12345678,12345678,12345678]
b: [-607311696,-609996928,0,-608522976]

Thomas


-----BEGIN PGP SIGNATURE-----

iD8DBQFFpCBCLK5blCcjpWoRAqMaAJ99ABE9fuCCRBZ65VbRF40BPYNsZwCfblY2
DDkPgs/4g0YjXFRyQUSy+sA=
=w9m/
-----END PGP SIGNATURE-----


More information about the Digitalmars-d-learn mailing list