Serializer class

thedeemon via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Feb 22 11:13:08 PST 2017


On Wednesday, 22 February 2017 at 18:34:26 UTC, houdoux09 wrote:
> void Read(T)(T value)
> {
>    foreach(i, mm; value.tupleof)
>    {
>       writeln(__traits(identifier, value.tupleof[i]), " = ", 
> mm);
>
>       if(isArray!(typeof(mm)))
>       {
>           Read(mm[0]); //Error
>       }
>    }
> }

You need to use "static if" here inside foreach. Otherwise the 
body of your "if" gets compiled for all the different fields of 
"value" and of course fails for the fields that are not arrays.



More information about the Digitalmars-d-learn mailing list