How would you do this in D?

Jonathan M Davis jmdavisProg at gmx.com
Tue May 10 18:11:53 PDT 2011


On 2011-05-10 18:06, Jose Armando Garcia wrote:
> Thanks. I should have read
> http://www.digitalmars.com/d/2.0/template.html more carefully.
> 
> "Multiple instantiations of a TemplateDeclaration with the same
> TemplateArgumentList, before implicit conversions, all will refer to
> the same instantiation."
> 
> The default values which are evaluated at the call site are part of
> the TemplateArgumentList.

Yes, default arguments are evaluated at the call site, not where the code is 
declared. I believe that C++ has the opposite behavior, so it's not uncommon 
that people miss that. It's _very_ useful though - particularly when dealing 
with __FILE__ and __LINE__.

- Jonathan M Davis


More information about the Digitalmars-d mailing list