Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

dmd.templatesem

Template semantics.
Authors:
void templateDeclarationSemantic(Scope* sc, TemplateDeclaration tempdecl);
Perform semantic analysis on template.
Parameters:
Scope* sc context
TemplateDeclaration tempdecl template declaration
MATCH matchWithInstance(Scope* sc, TemplateDeclaration td, TemplateInstance ti, ref Objects dedtypes, ArgumentList argumentList, int flag);
Given that ti is an instance of this TemplateDeclaration, deduce the types of the parameters to this, and store those deduced types in dedtypes[].
Parameters:
Scope* sc context
TemplateDeclaration td template
TemplateInstance ti instance of td
Objects dedtypes fill in with deduced types
ArgumentList argumentList arguments to template instance
int flag 1 - don't do semantic() because of dummy types 2 - don't change types in matchArg()
Returns:
match level.
bool evaluateConstraint(TemplateDeclaration td, TemplateInstance ti, Scope* sc, Scope* paramscope, Objects* dedargs, FuncDeclaration fd);
Check to see if constraint is satisfied.
void formatParamsWithTiargs(ref TemplateParameters parameters, ref Objects tiargs, bool variadic, ref OutBuffer buf);
Append to buf a textual representation of template parameters with their arguments.
Parameters:
TemplateParameters parameters the template parameters
Objects tiargs the correspondeing template arguments
bool variadic if it's a variadic argument list
OutBuffer buf where the text output goes
Scope* createScopeForTemplateParameters(TemplateDeclaration td, TemplateInstance ti, Scope* sc);
Create a scope for the parameters of the TemplateInstance ti in the parent scope sc from the ScopeDsymbol paramsym.
If paramsym is null a new ScopeDsymbol is used in place of paramsym.
Parameters:
TemplateDeclaration td template that ti is an instance of
TemplateInstance ti the TemplateInstance whose parameters to generate the scope for.
Scope* sc the parent scope of ti
Returns:
new scope for the parameters of ti
MATCH leastAsSpecialized(Scope* sc, TemplateDeclaration td, TemplateDeclaration td2, ArgumentList argumentList);
Determine partial specialization order of td vs td2.
Parameters:
Scope* sc context
TemplateDeclaration td first template
TemplateDeclaration td2 second template
ArgumentList argumentList arguments to template
Returns:
MATCH - td is at least as specialized as td2 MATCH.nomatch - td2 is more specialized than td
MATCHpair deduceFunctionTemplateMatch(TemplateDeclaration td, TemplateInstance ti, Scope* sc, ref FuncDeclaration fd, Type tthis, ArgumentList argumentList);
Match function arguments against a specific template function.
Parameters:
TemplateDeclaration td template declaration for template instance
TemplateInstance ti template instance. ti.tdtypes will be set to Expression/Type deduced template arguments
Scope* sc instantiation scope
FuncDeclaration fd Partially instantiated function declaration, which is set to an instantiated function declaration
Type tthis 'this' argument if !NULL
ArgumentList argumentList arguments to function
Returns:
match pair of initial and inferred template arguments
RootObject declareParameter(TemplateDeclaration td, Scope* sc, TemplateParameter tp, RootObject o);
Declare template parameter tp with value o, and install it in the scope sc.
void functionResolve(ref MatchAccumulator m, Dsymbol dstart, Loc loc, Scope* sc, Objects* tiargs, Type tthis, ArgumentList argumentList, void delegate(const(char)*) scope errorHelper = null);
Given function arguments, figure out which template function to expand, and return matching result.
Parameters:
MatchAccumulator m matching result
Dsymbol dstart the root of overloaded function templates
Loc loc instantiation location
Scope* sc instantiation scope
Objects* tiargs initial list of template arguments
Type tthis if !NULL, the 'this' pointer argument
ArgumentList argumentList arguments to function
void delegate(const(char)*) scope errorHelper delegate to send error message to if not null