Jump to Table of Contents Collapse Sidebar

Extending structured bindings to be more like variable declarations

Published Proposal,

This version:
Nicolas Lesser (blitzrakete[at]gmail[dot][com])
ISO/IEC JTC1/SC22/WG21 14882: Programming Language — C++


Making structured bindings more like first-class-citizen.

1. This revision

This revision contains only wording for the changes approved by EWG:

Read a previous revision to know more.

2. Proposed wording

Change [expr.prim.lambda.capture]p8 ( as follows:

If a lambda-expression explicitly captures an entity that is not odr-usable or captures a structured binding (explicitly or implicitly) , the program is ill-formed.

Change [expr.prim.lambda.capture]p12 ( as follows:

A bit-field , a structured binding, or a member of an anonymous union shall not be captured by reference.

Change [dcl.struct.bind]p1 (9.5) as follows:

If the assignment-expression in the initializer has array type A and no ref-qualifier is present, e has type cv A is defined by

attribute-specifier-seqopt decl-specifier-seq cv A e ;

where the decl-specifier-seq does not include the type-specifier auto and each element is copy-initialized or direct-initialized from the corresponding element of the assignment-expression as specified by the form of the initializer.

Add a sentence to [dcl.struct.bind]p1 (9.5) as follows:

If either the storage-class-specifier static or thread_local appears in the decl-specifier-seq of the structured binding declaration, then the declaration shall not be defined at namespace scope.

Change [dcl.dcl]p8 (10) as follows:

The decl-specifier-seq shall contain only the storage-class-specifiers static and thread_local, the type-specifier auto and cv-qualifiers.

Change [dcl.stc]p3 (10.1.1) as follows:

It shall be applied only to the names of variables of namespace or block scope , to structured binding declarations ([dcl.struct.bind]) and to the names of static data members.

Change [dcl.stc]p4 (10.1.1) as follows:

The static specifier can be applied only to names of variables and functions , to structured binding declarations ([dcl.struct.bind]), and to anonymous unions.