Closed katzdm closed 2 months ago
Planning to implement this function.
Let me know if there are any objections.
@BaLiKfromUA Sounds great.
A careful review through the content of dcl.struct.bind
could be worthwhile - In particular, note that a structured binding declaration proceeds by first introducing a "variable with a unique name e", followed by the declaration of n-many "names" which may or may not be variables; it is these "names" that are the structured bindings, rather than the implicit "variable with a unique name" (which we should avoid producing a reflection of at all).
Note also that there are three cases:
And that the structured bindings introduced for cases (1) and (3) are said only to be "lvalue(s) that refer to" subobjects of the implicit "variable with a unique name" - in particular, they are not variables (but the names introduced by case (2) are variables). The is_variable
metafunction should behave accordingly.
This godbolt, and the AST structure surfaced therein, demonstrates all three cases; it may be helpful with both the implementation and for writing tests. Please check that both is_structured_binding
and is_variable
return as expected for all three cases. It may or may not also be necessary to implement special cases for some other metafunctions (e.g., type_of
? also maybe extract
?); feel free to do so in the same PR, or in a follow-up PR, according to your preference. Please also add tests to cover any such "interesting" special cases, as you see fit.
The
is_structured_binding
metafunction was added in P2996R3.