[Accepted as a DR at the June, 2018 (Rapperswil) meeting.]
What is the point of declaration of a name introduced by a structured binding? If it's the point at which it appears, we're missing a rule to make it ill-formed to reference the name before its type is deduced (similar to what we have for 'auto'). [Suggestion: point of declaration is after the identifier-list, program is ill-formed if the name is mentioned before the end of the initializer.]
Are structured bindings permitted at namespace scope? There doesn't seem to be a rule against that. If so, what's their linkage? Is it intentional that static , extern are disallowed? Should we only allow automatic storage duration? [Suggestion: only permit automatic storage duration, per the design paper.]
(If the answer to 2 is yes...) is the declaration in a variable template permitted to use structured bindings? If so, how do you name the result? (The bindings themselves aren't introduced as template-names by the current wording.) If not, we're missing a restriction on that. [Suggestion: no to question 2.]
Did we intend to guarantee that the object whose members are denoted by bindings is kept "together":
auto f() -> int (&)[2]; auto [x, y] = f(); assert(&x + 1 == &y); // ok? struct S { int a, b, c; }; // standard-layout auto [a,b,c] = S(); assert(&((S*)&a)->b == &b); // ok?
(If yes, this means we can't synthesize independent variables for each element of an array or struct that's bound in this way, and it's harder to remove dead components of a destructured object.) Obviously we may need to keep the object together if it has a non-trivial destructor. [Suggestion: do not allow reaching the complete object from a binding.]
Should the copy->move promotion be permitted for a return of a structured binding?
struct A { string s; int n; };
string f() {
auto [s,n] = A();
return s; // copy required here?
}
[Suggestion: allow promotion to move -- as if the binding were a real local variable -- if the implicit underlying variable is not a reference. Maybe also allow NRVO, depending on answer to question 8.]