Ast.TemplateDeclaration Class
Namespace: Ast
Superclasses: AstNodeProperties
Represents the template_declaration nodes in the syntax tree of your code
Since R2026a
Description
TemplateDeclaration class represents the C++ syntax node template_declaration in your code and contains predicates to query properties and children of this node.
Predicates
| Type | Raisable | Printable |
|---|---|---|
TemplateDeclaration
| Yes | No |
This class defines these predicates that act on the objects of this class. In addition, objects of this class can access the predicates defined by the base class AstNodeProperties. An object of this class is an object of AstNodeProperties class.
| Predicates | Description | Example |
|---|---|---|
is(TemplateDeclaration &decl)
| The Example C++ code: template <typename T> void foo(T); Equivalent tree-sitter node: template_declaration The | The
rule CheckTemplateIs = { defectTemplateIs }
defect defectTemplateIs =
when
Cpp.TemplateDeclaration.is(&td)
and td.nodeText(&txt)
raise "Found template declaration: \"{txt}\""
on td
|
isa(Cpp.Node.Node node)
| The | The
rule CheckTemplateIs = { defectTemplateIs }
defect defectTemplateIs =
when
Cpp.Node.is(&node,&,&,&)
Cpp.TemplateDeclaration.isa(node)
and node.nodeText(&txt)
raise "Found template declaration: \"{txt}\""
on node
|
cast(Cpp.Node.Node node, required TemplateDeclaration &cast)
| The | The
rule CheckTemplateIs = { defectTemplateIs }
defect defectTemplateIs =
when
Cpp.Node.is(&node,&,&,&)
Cpp.TemplateDeclaration.cast(node, &TD)
and TD.nodeText(&txt)
raise "Found template declaration: \"{txt}\""
on node
|
parameters(TemplateDeclaration self, Cpp.Node.Node &child)
| The Example C++ code: template <typename T> void foo(T); The | This rule finds the parameters of a template declaration.
rule CheckParameters = { defectParameters }
defect defectParameters =
when
Cpp.TemplateDeclaration.parameters(¶ms)
and params.nodeText(&txt)
raise "TemplateDeclaration.parameters matched: "{txt}""
on params
|
parameters(TemplateDeclaration self, Cpp.Node.Node &child)
| The Example C++ code: template <typename T> friend class Bar; This
predicate matches the | This rule finds any
template <typename T>
friend class Bar;
rule CheckFriendDeclaration = { defectFriendDeclaration }
defect defectFriendDeclaration =
when
Cpp.TemplateDeclaration.is(&td)
and td.friendDeclaration(&fd)
and fd.nodeText(&txt)
raise "TemplateDeclaration.friendDeclaration matched: "{txt}""
on fd
|
functionDefinition(TemplateDeclaration self, Cpp.Node.Node
&child)
| The Example C++ code: template <typename T>
void foo(T) {} // function_definition nodeThe
| This rule finds function definition child nodes of a template declaration.
rule CheckTemplateFunctionDefinition = { defectTemplateFunctionDefinition }
defect defectTemplateFunctionDefinition =
when
Cpp.TemplateDeclaration.is(&td)
and td.functionDefinition(&fd)
and fd.nodeText(&txt)
raise "TemplateDeclaration.functionDefinition matched: "{txt}""
on fd
|
requiresClause(TemplateDeclaration self, Cpp.Node.Node
&child)
| The Example C++ code: template <typename T> requires C<T> void bar(T); The | This rule finds the
rule CheckRequiresClause = { defectRequiresClause }
defect defectRequiresClause =
when
Cpp.TemplateDeclaration.is(&td)
and td.requiresClause(&rc)
and rc.nodeText(&txt)
raise "TemplateDeclaration.requiresClause matched: '{txt}'"
on rc
|
aliasDeclaration(TemplateDeclaration self, Cpp.Node.Node
&child)
| The Example C++ code: template <typename T> using Ptr = T*; The
| This rule finds a
rule CheckAliasDeclaration = { defectAliasDeclaration }
defect defectAliasDeclaration =
when
Cpp.TemplateDeclaration.is(&td)
and td.aliasDeclaration(&ad)
and ad.nodeText(&txt)
raise "TemplateDeclaration.aliasDeclaration matched: "{txt}""
on ad
|
templateDeclaration(TemplateDeclaration self, Cpp.Node.Node
&child)
| The Example C++ code: template <typename T>
template <typename U>
struct S2 {};The | This rule finds nested template declarations.
rule CheckTemplateDeclaration = { defectTemplateDeclaration }
defect defectTemplateDeclaration =
when
Cpp.TemplateDeclaration.is(&td)
and td.templateDeclaration(&nestedTd)
and nestedTd.nodeText(&txt)
raise "Found nested template declaration: '{txt}'"
on nestedTd
|
conceptDefinition(TemplateDeclaration self, Cpp.Node.Node
&child)
| The Example C++ code: template <typename T>
concept C = requires(T t) { t + t; };The
| This rule detects template declarations that introduce a concept.
rule CheckConceptDefinition = { defectConceptDefinition }
defect defectConceptDefinition =
when
Cpp.TemplateDeclaration.is(&td)
and td.conceptDefinition(&cd)
and cd.nodeText(&txt)
raise "Found template concept definition: "{txt}""
on cd
|
typeSpecifier(TemplateDeclaration self, Cpp.Node.Node &child)
| The Example C++ code: template <typename T> struct S; The | This example finds template declarations whose parameter list includes a type specifier.
rule CheckTemplateTypeSpecifier = { defectTemplateTypeSpecifier }
defect defectTemplateTypeSpecifier =
when
Cpp.TemplateDeclaration.is(&td)
and td.typeSpecifier(&ts)
and ts.nodeText(&txt)
raise "TemplateDeclaration.typeSpecifier matched: '{txt}'"
on ts
|
declaration(TemplateDeclaration self, Cpp.Node.Node &child)
| The | This rule finds the declaration nodes within a template declaration. rule CheckTemplateDeclarationChild = { defectTemplateDeclarationChild }
defect defectTemplateDeclarationChild =
when
Cpp.TemplateDeclaration.is(&td)
and td.declaration(&decl) // &decl is the output child node bound by the predicate
and decl.nodeText(&txt)
raise "TemplateDeclaration.declaration matched: "{txt}""
on decl
|
Version History
Introduced in R2026a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)