tupleof.length of a class in a template return 0

"Michaël "Michaël
Wed Apr 18 20:04:38 PDT 2012


On Wednesday, 18 April 2012 at 16:56:39 UTC, SomeDude wrote:
> On Tuesday, 17 April 2012 at 00:04:16 UTC, Michaël Larouche 
> wrote:
>> My template works with a struct but when I try to mixin my 
>> template in a class, I get compile error because 
>> T.tupleof.length returns 0.
>>
>> Here's the whole code:
>> http://ideone.com/UR6YU
>
> For what it's worth, dmd 2.059 (it seems you are using v2.042) 
> gives this message:
>
> serial.d(21): Error: class serial.MyObject no size yet for 
> forward reference
> serial.d(11): Error: template instance 
> serial.GenerateFieldSerialization!(MyObject,0,"m_id","m_data","AMethod","AutoDelete","AnotherMethod","RefCount","Method1","toString","toHash","opCmp","opEquals","Monitor","factory") 
> error instantiating
>
> According to Kenji Hara, "tupleof property requires complete 
> semantic analysis to get the fields of a type."
>
> http://d.puremagic.com/issues/show_bug.cgi?id=7249
>
> If you haven't solved your problem yet, you may try the 
> workaround described or have a look at the result of googling 
> this:
> "no size yet for forward reference" site:digitalmars.com/d

Reading the bug thread, I am wondering why my template worked in 
a struct but not inside a class.

Anyway, I decided to move my mixin outside the struct/class and 
abuse UFCS instead. Now everything works like a charm :)


More information about the Digitalmars-d-learn mailing list