Recursive template instantiation

ag0aep6g via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Mar 13 16:07:48 PDT 2017


On 03/14/2017 12:02 AM, Stefan Koch wrote:
> On Monday, 13 March 2017 at 22:59:36 UTC, ag0aep6g wrote:
[...]
>> ----
>> struct A(T) {
>>     void m() {
>>         char[T.sizeof] data;
>>     }
>> }
>> /* ... rest as above ... */
>> ----
>>
>> I don't see how the destructor makes a difference. Soo, bug?
>
> Try to use m.

Works no problem?

----
struct A(T) {
     void m() {
         char[T.sizeof] data;
         import std.stdio;
         writeln(T.sizeof);
     }
}

struct B(T) {
     A!T foo;
}

struct C {
     B!C bar;
}

void main() {
     C c;
     c.bar.foo.m();
}
----

Prints "1".


More information about the Digitalmars-d-learn mailing list