template instantiation question

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Mar 18 15:15:53 PDT 2015


(My earlier response seems to be lost; trying one more time.)

On 03/18/2015 12:09 PM, Dmitri Makarov wrote:

 > On Wednesday, 18 March 2015 at 18:26:07 UTC, Ali Çehreli wrote:
 >> $ nm b.o | grep transmogrify
 >> 0000000000000000 W _D1c8__T1CTvZ1C12transmogrifyMFNaNbNiNfZi
 >
 > What compiler do you use?

dmd git head. I used simpler files:

// a.d
module a;

import c;
import b;

auto foo()
{
     auto c = C!void();
     return c.transmogrify();
}

void main()
{
     assert(.foo() == b.foo());
}

// b.d
module b;

import c;

auto foo()
{
     auto c = C!void();
     return c.transmogrify();
}

// c.d
module c;

struct C(T) {
   int transmogrify() {
     return 42;
   }
}

Then I built the program like this:

$ dmd a.d -c
$ dmd b.d -c
$ dmd c.d -c
$ dmd a.o b.o c.o

Ali



More information about the Digitalmars-d-learn mailing list