Cpp.AlignofExpression Class
Namespace: Cpp
Superclasses: AstNodeProperties
Represents the alignof_expression nodes in the syntax tree of your code
Since R2026a
Description
The PQL class AlignofExpression represents the node alignof_expression in the syntax tree of your code.
// minimal example showing alignof expressions
#include <cstddef>
int a = alignof(int);
int b = alignof(double);
int c = alignof(a);
int main() { return a + b + c; }The three alignof(...) usages in the C++ demo correspond to alignof_expression nodes; PQL AlignofExpression predicates operate on those nodes.
Predicates
| Type | Raisable | Printable |
|---|---|---|
AlignofExpression
| 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 AlignofExpression &ae)
| Checks that a node is an alignof_expression and returns it as &ae for further inspection. |
This PQL defect checks for any defect find_alignof =
when
Cpp.AlignofExpression.is(&ae)
and ae.nodeText(&txt)
raise "Found alignof: {txt}"
on aeIn this C++ code, the defect finds each
#include <cstddef>
int x = alignof(long);
int main() { return x; } |
cast(Cpp.Node.Node node, required AlignofExpression &cast)
| If the generic node is an alignof_expression, this binds the alignof_expression to &cast so you can treat it with AlignofExpression predicates. |
This PQL defect checks whether an arbitrary node is actually an defect cast_to_alignof =
when
Cpp.Node.is(&n, &,&,&)
and Cpp.AlignofExpression.cast(n, &ae)
and ae.nodeText(&txt)
raise "Node is alignof: {txt}"
on aeIn this C++ code, the defect finds an
#include <cstddef>
int y = alignof(char);
int main() { return y; } |
isa(Cpp.Node.Node node)
| Returns true when the provided generic node is an alignof_expression; useful in boolean checks or negation. |
This PQL defect checks for nodes that are defect isa_alignof =
when
Cpp.Node.is(&n, &,&,&)
and Cpp.AlignofExpression.isa(n)
and n.nodeText(&txt)
raise "isa confirms alignof: {txt}"
on nIn this C++ code, the predicate identifies the
#include <cstddef>
int z = alignof(short);
int main() { return z; } |
type(AlignofExpression self, Cpp.Node.Node &child)
| Matches the type node inside the alignof(...) expression (e.g., the int in alignof(int)), returning it as &child. |
This PQL defect checks for the inner type node of an defect alignof_type =
when
Cpp.AlignofExpression.is(&ae)
and ae.type(&ty)
and ty.nodeText(&txt)
raise "alignof type: {txt}"
on aeIn this C++ code, the defect extracts the type used inside each
#include <cstddef>
int a = alignof(long long);
int b = alignof(unsigned int);
int main() { return a + b; } |
getEnclosingAlignofExpression(Cpp.Node.Node child, required AlignofExpression &parent)
| Finds the nearest enclosing alignof_expression ancestor of child and binds it to &parent. | This PQL defect checks for nodes that are inside an
defect parent_alignof =
when
Cpp.Node.is(&inner, &,&,&)
and Cpp.AlignofExpression.getEnclosingAlignofExpression(inner, &ae)
and ae.nodeText(&txt)
raise "Enclosing alignof: {txt}"
on aeIn this C++ code, the defect finds nodes that have
an enclosing parent
#include <cstddef>
int v = alignof(unsigned long);
int main() { return v; } |
isEnclosedInAlignofExpression(Cpp.Node.Node child)
| Returns true when child has an alignof_expression ancestor; useful to detect usage contexts within alignof(...). |
This PQL defect checks for any node that lives inside an defect inside_alignof =
when
Cpp.Node.is(&n, &,&,&)
and Cpp.AlignofExpression.isEnclosedInAlignofExpression(n)
and n.nodeText(&txt)
raise "Node inside alignof: {txt}"
on nIn this C++ code, the defect detects the identifier or type node that appears within an
#include <cstddef>
int u = alignof(int);
int main() { return u; } |
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)