View source code
Display the source code in dmd/dtemplate.d from which thispage was generated on github.
Report a bug
If you spot a problem with this page, click here to create aBugzilla 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 usinglocal clone.

Module dmd.dtemplate

Defines TemplateDeclaration, TemplateInstance and a few utilities

This modules holds the two main template types: TemplateDeclaration, which is the user-provided declaration of a template, and TemplateInstance, which is an instance of a TemplateDeclaration with specific arguments.

Template Parameter

Additionally, the classes for template parameters are defined in this module. The base class, TemplateParameter, is inherited by: - TemplateTypeParameter - TemplateThisParameter - TemplateValueParameter - TemplateAliasParameter - TemplateTupleParameter

Templates semantic

The start of the template instantiation process looks like this: - A TypeInstance or TypeIdentifier is encountered. TypeInstance have a bang (e.g. Foo!(arg)) while TypeIdentifier don't. - A TemplateInstance is instantiated - Semantic is run on the TemplateInstance (see dmd.dsymbolsem) - The TemplateInstance search for its TemplateDeclaration, runs semantic on the template arguments and deduce the best match among the possible overloads. - The TemplateInstance search for existing instances with the same arguments, and uses it if found. - Otherwise, the rest of semantic is run on the TemplateInstance.

Documentation

https://dlang.org/phobos/dmd_dtemplate.html

Coverage

https://codecov.io/gh/dlang/dmd/src/master/compiler/src/dmd/dtemplate.d

Functions

NameDescription
arrayObjectIsError(args) Are any of the Objects an error?
definitelyValueParameter(e) Return true if e could be valid only as a template value parameter. Return false if it might be an alias or tuple. (Note that even in this case, it could still turn out to be a value).
getType(o) Try to get arg as a type.
isError(o) Is this Object an error?
isExpression(o) These functions substitute for dynamic_cast. dynamic_cast does not work on earlier versions of gcc.
printTemplateStats(listInstances, eSink) Print informational statistics on template instantiations.
reliesOnTemplateParameters(t, tparams) Check whether the type t representation relies on one or more the template parameters.
reliesOnTident(t, tparams, iStart) Check whether the type t representation relies on one or more the template parameters.

Classes

NameDescription
TemplateAliasParameter
TemplateDeclaration [mixin] template Identifier (parameters) [Constraint]
TemplateInstance
TemplateMixin
TemplateParameter
TemplateThisParameter
TemplateTupleParameter
TemplateTypeParameter
TemplateValueParameter

Structs

NameDescription
TemplateStats Collect and print statistics on template instantiations.

Authors

Walter Bright

License

Boost License 1.0