Cpp.StructuredBindingDeclarator Class
Namespace: Cpp
Superclasses: AstNodeProperties
Represents the structured_binding_declarator nodes in the syntax tree of your code
Since R2026a
Description
The PQL class StructuredBindingDeclarator represents the node structured_binding_declarator in the syntax tree of your code.
#include <utility>
#include <tuple>
std::pair<int,int> foo() { return {1,2}; }
void bar() {
auto [x, y] = foo(); // structured_binding_declarator node covering "x, y"
}The auto [x, y] = foo(); line contains the
structured_binding_declarator node.
Predicates
| Type | Raisable | Printable |
|---|---|---|
StructuredBindingDeclarator
| 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 StructuredBindingDeclarator &sbd)
| Matches a structured_binding_declarator node and returns it as &sbd. Use this to directly select structured binding declarators. |
This PQL defect checks for any structured binding declarator node in the source. defect find_sbd =
when
Cpp.StructuredBindingDeclarator.is(&sbd)
and sbd.nodeText(&txt)
raise "Found structured binding: \"{txt}\""
on sbdIn this C++ code, the defect finds the structured binding declarator that declares
#include <utility>
std::pair<int,int> foo() { return {1,2}; }
void f() {
auto [x, y] = foo(); // matches
} |
cast(Cpp.Node.Node node, required StructuredBindingDeclarator &cast)
| Checks whether a generic Cpp.Node.Node is a structured_binding_declarator and, if so, returns it as &cast. Use when you have a node of unknown kind. |
This PQL defect checks whether a generic node is a structured binding declarator. defect cast_to_sbd =
when
Cpp.Node.is(&node, &,&,&)
and Cpp.StructuredBindingDeclarator.cast(node, &sbd)
and sbd.nodeText(&txt)
raise "Casted to structured binding: \"{txt}\""
on sbdIn this C++ code, the defect detects the structured binding by first treating the parse node generically and then casting it.
#include <utility>
std::pair<int,int> foo() { return {1,2}; }
void g() {
auto [a, b] = foo(); // matches
} |
isa(Cpp.Node.Node node)
| Returns true if the given Cpp.Node.Node is a structured_binding_declarator; use for boolean checks or negation (not ... isa(node)). |
This PQL defect checks for nodes that are structured binding declarators using a boolean test. defect isa_check =
when
Cpp.Node.is(&node, &,&,&)
and Cpp.StructuredBindingDeclarator.isa(node)
raise "Node is a structured binding declarator"
on nodeIn this C++ code, the defect confirms that the parsed node corresponding to the bracketed declarator is a structured binding.
#include <tuple>
std::tuple<int,int> t() { return {1,2}; }
void h() {
auto [p, q] = t(); // matches
} |
identifier(StructuredBindingDeclarator self, Cpp.Node.Node &child)
| Enumerates each identifier child inside the structured binding (e.g., x and y in auto [x, y] = ...) and returns them as &child. |
This PQL defect checks for individual identifier nodes within a structured binding declarator. defect sbd_identifier =
when
Cpp.StructuredBindingDeclarator.is(&sbd)
and sbd.identifier(&id)
and id.nodeText(&txt)
raise "Structured binding identifier: \"{txt}\""
on idIn this C++ code, the defect finds each declared name inside the structured binding (
#include <utility>
std::pair<int,int> foo() { return {1,2}; }
void k() {
auto [x, y] = foo(); // identifier predicate matches `x` then `y`
} |
getEnclosingStructuredBindingDeclarator(Cpp.Node.Node child, required StructuredBindingDeclarator &parent)
| Finds the nearest enclosing structured_binding_declarator for a given child node and returns it as &parent. | This PQL defect checks for the parent structured binding declarator that has a generic child node. defect enclosing_sbd =
when
Cpp.Node.is(&child, &,&,&)
and Cpp.StructuredBindingDeclarator.getEnclosingStructuredBindingDeclarator(child, &parent)
and parent.nodeText(&txt)
raise "Enclosing structured binding: \"{txt}\""
on parentIn this C++ code, the defect identifies the structured binding that has child nodes.
#include <utility>
std::pair<int,int> foo() { return {1,2}; }
void m() {
auto [x, y] = foo(); // matches
} |
isEnclosedInStructuredBindingDeclarator(Cpp.Node.Node
child) | Matches any ancestor structured_binding_declarator of
child. | This PQL defect checks for the ancestor structured binding declarator that has a generic descendent node. defect enclosed_in_sbd =
when
Cpp.Node.is(&child, &,&,&)
and Cpp.StructuredBindingDeclarator.isEnclosedInStructuredBindingDeclarator(n)
raise "Node is inside structured binding declarator"
on nIn this C++ code, the defect confirms that the
identifier nodes
#include <utility>
std::pair<int,int> foo() { return {1,2}; }
void m() {
auto [x, y] = foo(); // matches
} |
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)