Serializer class
Jacob Carlborg via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Feb 24 05:10:07 PST 2017
On 2017-02-22 20:13, thedeemon wrote:
> 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.
I'm pretty sure you need to use "value.tupleof[i][0]" instead of "mm[0]"
as well.
--
/Jacob Carlborg
More information about the Digitalmars-d-learn
mailing list