Are templated functions always re-constructed?
H. S. Teoh
hsteoh at quickfur.ath.cx
Wed Nov 17 17:02:45 UTC 2021
On Wed, Nov 17, 2021 at 11:12:22AM +0000, rempas via Digitalmars-d-learn wrote:
> On Tuesday, 16 November 2021 at 21:30:08 UTC, H. S. Teoh wrote:
> >
> > Short answer: a template called with the same CT arguments will only
> > be instantiated once, and reused thereafter.
> >
> > Long answer: the above applies per compilation. If you compile your
> > sources separately, there may be multiple instantiations of the
> > template with the same CT arguments. However, unless something went
> > wrong, these duplicates will be dropped by the linker.
[...]
> Thanks! I mostly care about compilation times rather than duplication
> tbh
Regular (non-recursive) templates generally will not cause a noticeable
change in compilation times. The trouble usually only starts when you
start using recursive templates. Or when your templates are nested
unreasonably deep (though this also usually only happens when there's
recursive instantiation somewhere).
T
--
Computerese Irregular Verb Conjugation: I have preferences. You have biases. He/She has prejudices. -- Gene Wirchenko
More information about the Digitalmars-d-learn
mailing list