Cpp.RequiresClause Class
Namespace: Cpp
Superclasses: AstNodeProperties
Represents the requires_clause nodes in the syntax tree of your code
Since R2026a
Description
The PQL class Cpp.RequiresClause represents the node requires_clause in the syntax tree of your code.
template<typename T>
requires std::integral<T>
void foo(T t) {}The requires std::integral<T> part of the example corresponds to the requires_clause node handled by Cpp.RequiresClause.
Predicates
| Type | Raisable | Printable |
|---|---|---|
RequiresClause
| 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 RequiresClause &rc)
| Checks whether a syntax node is a requires_clause and binds
it to rc. Use this to directly select requires
clauses. | This PQL defect checks for defect defectIs =
when
Cpp.RequiresClause.is(&rc)
and rc.nodeText(&txt)
raise "RequiresClause.is matched: \"{txt}\""
on rcIn this C++ code the defect finds the
template<typename T>
requires (sizeof(T) <= 8 && sizeof(T) >= 1)
void foo(T) {}
int main() {
foo(42); // OK - int satisfies the requirements
foo('a'); // OK - char satisfies the requirements
return 0;
}
|
cast(Cpp.Node.Node node, required RequiresClause &cast)
| Treats an arbitrary Node as a
requires_clause if its runtime kind matches and binds it to
cast. Use this when you have a generic node and need
requires_clause-specific predicates. | This PQL defect checks for defect defectCast =
when
Cpp.TemplateDeclaration.is(&td)
and td.getADescendant(&node)
and Cpp.RequiresClause.cast(node, &rc)
and rc.nodeText(&txt)
raise "RequiresClause.cast matched: \"{txt}\""
on rcIn this C++ code the defect finds a
template<typename T>
requires (sizeof(T) <= 8 && sizeof(T) >= 1)
void foo(T) {}
int main() {
foo(42); // OK - int satisfies the requirements
foo('a'); // OK - char satisfies the requirements
return 0;
}
|
isa(Cpp.Node.Node node)
| Checks whether a generic Node is a
requires_clause without binding it. Use this for boolean tests
or negations. | This PQL defect checks whether a generic defect defectIsa =
when
Cpp.TemplateDeclaration.is(&td)
and td.getADescendant(&node)
and Cpp.RequiresClause.isa(node)
raise "Node is a RequiresClause"
on tdIn this C++ code the defect verifies that a
template declaration contains a
template<typename T>
requires (sizeof(T) <= 8 && sizeof(T) >= 1)
void foo(T) {}
int main() {
foo(42); // OK - int satisfies the requirements
foo('a'); // OK - char satisfies the requirements
return 0;
}
|
constraint(RequiresClause self, Cpp.Node.Node &child)
| Selects the constraint expression node inside a
requires_clause and binds it to child. Use
this to inspect the concept or expression following
requires. | This PQL defect checks for the constraint expression inside a
defect defectConstraint =
when
Cpp.RequiresClause.is(&rc)
and rc.constraint(&constraint)
and constraint.nodeText(&txt)
raise "RequiresClause.constraint matched: \"{txt}\""
on constraintIn this C++ code the defect extracts the
#include <concepts>
template<typename T>
requires std::integral<T>
void foo(T) {}
int main() {} |
getEnclosingRequiresClause(Cpp.Node.Node child, required RequiresClause
&parent)
| Finds the nearest enclosing requires_clause that contains
child and binds it to parent. Use this to
map inner nodes back to their requires context. | This PQL defect checks for the nearest enclosing
defect defectEnclosing =
when
Cpp.TypeIdentifier.is(&id)
and id.toNode(&node)
and Cpp.RequiresClause.getEnclosingRequiresClause(node, &rc)
raise "Identifier is inside requires clause"
on idIn this C++ code the defect finds type identifiers
that appear inside a
#include <concepts>
template<typename T>
requires std::integral<T>
void foo(T) {}
int main() {} |
isEnclosedInRequiresClause(Cpp.Node.Node child)
| Checks whether child has any
requires_clause ancestor. Use this to filter nodes that appear
within requires clauses. | This PQL defect checks whether a given type identifier is anywhere inside
a
defect defectIsEnclosed =
when
Cpp.TypeIdentifier.is(&id)
and id.toNode(&node)
and Cpp.RequiresClause.isEnclosedInRequiresClause(node)
raise "Identifier enclosed in requires clause"
on idIn this C++ code the defect flags type identifiers
that belong to the
#include <concepts>
template<typename T>
requires std::integral<T>
void foo(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.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)