Cpp.RequiresExpression Class
Namespace: Cpp
Superclasses: AstNodeProperties
Represents the requires_expression nodes in the syntax tree of your code
Since R2026a
Description
The PQL class Cpp.RequiresExpression represents the node requires_expression in the syntax tree of your code.
template<typename T>
concept Addable = requires (T t) { t + t; };
int main() {}The requires (T t) { t + t; } line is the requires_expression node that Cpp.RequiresExpression models.
Predicates
| Type | Raisable | Printable |
|---|---|---|
RequiresExpression
| 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(required RequiresExpression &re)
| Matches a requires_expression node and binds it to re for further inspection or reporting. |
This PQL defect checks for any defect findRequiresIs =
when
Cpp.RequiresExpression.is(&re)
and re.nodeText(&txt)
raise "requires found: \"{txt}\""
on reIn this C++ code, the defect finds the
template<typename T>
concept Addable = requires (T t) { t + t; };
int main() {} |
cast(Cpp.Node.Node node, required RequiresExpression &cast)
| Checks whether the given node is a requires_expression and if so binds it to cast for requiring-specific queries. |
This PQL defect checks whether an arbitrary defect findRequiresByNode =
when
Cpp.Node.is(&n, &,&,&)
and Cpp.RequiresExpression.cast(n, &re)
and re.nodeText(&txt)
raise "node cast to requires: \"{txt}\""
on reIn this C++ code, the defect tests a generic syntax node and confirms it is the
template<typename T>
concept Addable = requires (T t) { t + t; };
int main() {} |
isa(Cpp.Node.Node node)
| Returns true when node is a requires_expression allowing checks or negations against arbitrary Node values. |
This PQL defect checks whether a given defect checkIsa =
when
Cpp.Node.is(&n, &,&,&)
and Cpp.RequiresExpression.isa(n)
raise "Node is a requires_expression"
on nIn this C++ code, the defect identifies the
template<typename T>
concept Addable = requires (T t) { t + t; };
int main() {} |
parameters(RequiresExpression self, Cpp.Node.Node &child)
| Matches the parameter-list node of a requires_expression and binds it to child. |
This PQL defect checks for the parameter list portion of a defect requiresParameters =
when
Cpp.RequiresExpression.is(&re)
and re.parameters(¶ms)
and params.nodeText(&txt)
raise "requires parameters: \"{txt}\""
on paramsIn this C++ code, the defect extracts the
template<typename T>
concept Addable = requires (T t) { t + t; };
int main() {} |
requirements(RequiresExpression self, Cpp.Node.Node &child)
| Matches the requirement-body node of a requires_expression and binds it to child. |
This PQL defect checks for the block of requirements inside a defect requiresBody =
when
Cpp.RequiresExpression.is(&re)
and re.requirements(&body)
and body.nodeText(&txt)
raise "requires body: \"{txt}\""
on bodyIn this C++ code, the defect finds the
template<typename T>
concept Addable = requires (T t) { t + t; };
int main() {} |
getEnclosingRequiresExpression(Cpp.Node.Node child, required RequiresExpression &parent)
| Finds the nearest enclosing requires_expression ancestor of child and binds it to parent. |
This PQL defect checks for the closest defect findEnclosingRequires =
when
Cpp.Identifier.is(&id)
and Cpp.RequiresExpression.getEnclosingRequiresExpression(id, &re)
and re.nodeText(&txt)
raise "enclosing requires: \"{txt}\""
on reIn this C++ code, the defect takes an identifier inside the requirements and finds the surrounding
template<typename T>
concept Addable = requires (T t) { t + t; }; // identifier 't' is inside the requirements block
int main() {} |
isEnclosedInRequiresExpression(Cpp.Node.Node child)
| True when child has any requires_expression ancestor letting you match nodes located inside a requires context. |
This PQL defect checks whether a node is located anywhere inside a defect checkInsideRequires =
when
Cpp.Identifier.is(&id)
and Cpp.RequiresExpression.isEnclosedInRequiresExpression(id)
raise "identifier is inside a requires expression"
on idIn this C++ code, the defect detects that the identifier
template<typename T>
concept Addable = requires (T t) { t + t; };
int main() {} |
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)