template instantiation question

Dmitri Makarov via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Mar 18 11:03:22 PDT 2015


I have three modules a.d, b.d, and c.d:

file a.d:```
module i.a;

import i.c, i.b;

final class A {
public:
   void foo() {
     a.transmogrify();
   }
   S!void a;
}
```
--------------
file b.d:```
module i.b;

import i.a, i.c;

class B {
public:
   S!void b;
}
```
--------------
file c.d:```
module i.c;

struct C {}

struct S(T) {
   C transmogrify() {
     return C();
   }
}
```
--------------
When these modules compiled separately, I assume, both a.o and 
b.o contain a definition of i.c.S!void.S.transmogrify() instance. 
Is this correct? If so, how is the symbol redefinition resolved 
when the three object files are linked into a single executable?


More information about the Digitalmars-d-learn mailing list