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.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- 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)