spec: template instantiations

Dibyendu Majumdar mobile at majumdar.org.uk
Fri Nov 20 20:59:56 UTC 2020


I don't under this:

https://dlang.org/spec/template.html#instantiation_scope

The text seems to contradict the example.

If a template declares multiple entities then is it possible to 
instantiate all of them at one or is each entity instantiated 
separately?

Suppose we have:

template Transformer(From, To) // From and To are types, too
{
     To transform(From from)
     {
         import std.conv;
         return to!(To)(from);
     }

     class Modificator
     {
         From f;
         To t;
         this(From f) { /*...*/ }
     }
}

Then is there way to instantiate both 'transform' and 
'Modificator' at once?





More information about the Digitalmars-d mailing list