Templates class member functions not conditional?
Jonathan M Davis
jmdavisProg at gmx.com
Tue Sep 11 08:37:43 PDT 2012
On Tuesday, September 11, 2012 15:12:57 monarch_dodra wrote:
> On Tuesday, 11 September 2012 at 11:33:05 UTC, bearophile wrote:
> > monarch_dodra:
> >> Is this not the case for D? Or is it currently a limitation?
> >
> > In this case I think D is working as designed. All functions
> > inside a template are created when you instantiate it.
> >
> > [SNIP]
> >
> > Bye,
> > bearophile
>
> Well, the functions are declared inside the template, but do they
> have to be validated and compiled?
>
> I mean, technically, in C++, the functions are also there, just
> not compiled and validated...
Anything inside a template is not compiled unless the template is
instantiated, but if the template is instantiated, the entire template is
instantiated and compiled (save for static if branches which aren't followed
or inner templates which aren't instantiated). If C++ doesn't work that way as
well, I find that to be very bizarre. Regardless though, that's how D works.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list