Where are the template members?

Simen Kjaeraas simen.kjaras at gmail.com
Wed Dec 5 04:46:25 PST 2012


On 2012-43-05 10:12, Gor Gyolchanyan <gor.f.gyolchanyan at gmail.com> wrote:

> Aren't the template instances generated at the place of the template?
> The external code would instantiate the template, adding the instance
> information to the structure.
> Then the sizeof would just read the set of instantiated templates.
> This wouldn't require knowing about the code which instantiates the
> template.
> The only requirement would be to compute the size of the structure AFTER
> all template instances are generated.
> The only limitation would be that separate compilation passes could
> generate different structures due to different template instances, but
> that's not a problem, because the static templates go through the same
> limitation.

How is that not a problem?

The static templates get the same mangled name, and thus dupes can be
removed by the linker. If a type has variable size, how is one to know
that size - be it for argument passing/returning purposes, array creation,
or whatever.

-- 
Simen


More information about the Digitalmars-d mailing list