serialization library - associative arrays ?
Thomas Kuehne
thomas-dloop at kuehne.cn
Thu Dec 21 23:35:09 PST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Christian Kamm schrieb am 2006-12-21:
>> static if(is(T == typeof(T.values[$])[typeof(T.keys[$])]){
>> // it is an AA, now do your KEY and VALUE magic
>> }
>
> Good idea! However, it doesn't compile for T = int, for example (unless
> that was changed between 0.173 and 0.177):
> - no property 'keys' for type 'int'
Wrong order..., this should work:
static if(is(typeof(T.values[0])[typeof(T.keys[0])] == T)){
// it is an AA, now do your KEY and VALUE magic
}
> Why is T.values[$] allowed, though - and is the [$] neccessary?
$ is used to get an element of the array. You can use any index for that
purpose.
Thomas
-----BEGIN PGP SIGNATURE-----
iD8DBQFFi5eGLK5blCcjpWoRAuezAJ9yI+lvn4loaEZX6LuSIZaynCmsQwCdEwOb
eC87B4x3YHpqC9TgYuzInDw=
=lhKg
-----END PGP SIGNATURE-----
More information about the Digitalmars-d-announce
mailing list