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:
License:
Source templatesem.d
Documentation https://dlang.org/phobos/dmd_templatesem.html
- void
templateDeclarationSemantic(Scope*sc, TemplateDeclarationtempdecl); - Perform semantic analysis on template.Parameters:
Scope* sccontext TemplateDeclaration tempdecltemplate declaration - MATCH
matchWithInstance(Scope*sc, TemplateDeclarationtd, TemplateInstanceti, ref Objectsdedtypes, ArgumentListargumentList, intflag); - 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* sccontext TemplateDeclaration tdtemplate TemplateInstance tiinstance of td Objects dedtypesfill in with deduced types ArgumentList argumentListarguments to template instance int flag1 - don't do semantic() because of dummy types 2 - don't change types in matchArg() Returns:match level. - bool
evaluateConstraint(TemplateDeclarationtd, TemplateInstanceti, Scope*sc, Scope*paramscope, Objects*dedargs, FuncDeclarationfd); - Check to see if constraint is satisfied.
- void
formatParamsWithTiargs(ref TemplateParametersparameters, ref Objectstiargs, boolvariadic, ref OutBufferbuf); - Append to buf a textual representation of template parameters with their arguments.Parameters:
TemplateParameters parametersthe template parameters Objects tiargsthe correspondeing template arguments bool variadicif it's a variadic argument list OutBuffer bufwhere the text output goes - Scope*
createScopeForTemplateParameters(TemplateDeclarationtd, TemplateInstanceti, Scope*sc); - Create a scope for the parameters of the TemplateInstance
tiin the parent scope sc from the ScopeDsymbol paramsym.If paramsym is null a new ScopeDsymbol is used in place of paramsym.Parameters:TemplateDeclaration tdtemplate that ti is an instance of TemplateInstance tithe TemplateInstance whose parameters to generate the scope for. Scope* scthe parent scope of ti Returns:new scope for the parameters of ti - MATCH
leastAsSpecialized(Scope*sc, TemplateDeclarationtd, TemplateDeclarationtd2, ArgumentListargumentList); - Determine partial specialization order of
tdvstd2.Parameters:Scope* sccontext TemplateDeclaration tdfirst template TemplateDeclaration td2second template ArgumentList argumentListarguments to template Returns:MATCH - td is at least as specialized as td2 MATCH.nomatch - td2 is more specialized than td - MATCHpair
deduceFunctionTemplateMatch(TemplateDeclarationtd, TemplateInstanceti, Scope*sc, ref FuncDeclarationfd, Typetthis, ArgumentListargumentList); - Match function arguments against a specific template function.Parameters:
TemplateDeclaration tdtemplate declaration for template instance TemplateInstance titemplate instance. ti.tdtypes will be set to Expression/Type deduced template argumentsScope* scinstantiation scope FuncDeclaration fdPartially instantiated function declaration, which is set to an instantiated function declaration Type tthis'this' argument if !NULL ArgumentList argumentListarguments to function Returns:match pair of initial and inferred template arguments - RootObject
declareParameter(TemplateDeclarationtd, Scope*sc, TemplateParametertp, RootObjecto); - Declare template parameter tp with value o, and install it in the scope sc.
- void
functionResolve(ref MatchAccumulatorm, Dsymboldstart, Locloc, Scope*sc, Objects*tiargs, Typetthis, ArgumentListargumentList, void delegate(const(char)*) scopeerrorHelper= null); - Given function arguments, figure out which template function to expand, and return matching result.Parameters:
MatchAccumulator mmatching result Dsymbol dstartthe root of overloaded function templates Loc locinstantiation location Scope* scinstantiation scope Objects* tiargsinitial list of template arguments Type tthisif !NULL, the 'this' pointer argument ArgumentList argumentListarguments to function void delegate(const(char)*) scope errorHelperdelegate to send error message to if not null
Copyright © 1999-2025 by the D Language Foundation | Page generated by
Ddoc on Mon Mar 31 10:28:04 2025