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* sc
context TemplateDeclaration tempdecl
template 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* 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
(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 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
(TemplateDeclarationtd
, TemplateInstanceti
, 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
, TemplateDeclarationtd
, TemplateDeclarationtd2
, ArgumentListargumentList
); - Determine partial specialization order of
td
vstd2
.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
(TemplateDeclarationtd
, TemplateInstanceti
, Scope*sc
, ref FuncDeclarationfd
, Typetthis
, ArgumentListargumentList
); - 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 argumentsScope* 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
(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 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
Copyright © 1999-2024 by the D Language Foundation | Page generated by
Ddoc on Wed Dec 18 08:51:51 2024