<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2289</TITLE>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<STYLE TYPE="text/css">
  INS { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  .INS { text-decoration:none; background-color:#D0FFD0 }
  DEL { text-decoration:line-through; background-color:#FFA0A0 }
  .DEL { text-decoration:line-through; background-color: #FFD0D0 }
  @media (prefers-color-scheme: dark) {
    HTML { background-color:#202020; color:#f0f0f0; }
    A { color:#5bc0ff; }
    A:visited { color:#c6a8ff; }
    A:hover, a:focus { color:#afd7ff; }
    INS { background-color:#033a16; color:#aff5b4; }
    .INS { background-color: #033a16; }
    DEL { background-color:#67060c; color:#ffdcd7; }
    .DEL { background-color:#67060c; }
  }
  SPAN.cmnt { font-family:Times; font-style:italic }
</STYLE>
</HEAD>
<BODY>
<P><EM>This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
  Core Issues List revision 118b.
  See http://www.open-std.org/jtc1/sc22/wg21/ for the official
  list.</EM></P>
<P>2025-09-28</P>
<HR>
<A NAME="2289"></A><H4>2289.
  
Uniqueness of structured binding names
</H4>
<B>Section: </B>_N4868_.6.4.1&#160; [<A href="https://wg21.link/basic.scope.declarative">basic.scope.declarative</A>]
 &#160;&#160;&#160;

 <B>Status: </B>CD5
 &#160;&#160;&#160;

 <B>Submitter: </B>Richard Smith
 &#160;&#160;&#160;

 <B>Date: </B>2016-07-20<BR>


<P>[Accepted as a DR at the February, 2019 meeting.]</P>



<P>The current wording is not clear regarding examples like
the following:</P>

<PRE>
  struct A { int x; } a;
  struct B {} b; template&lt;int&gt; int &amp;get(const B&amp;);
  struct C {}; int c[1];
  auto [A] = a; //<SPAN CLASS="cmnt"> ok? </SPAN>
  auto [B] = b; //<SPAN CLASS="cmnt"> ok? </SPAN>
  auto [C] = c; //<SPAN CLASS="cmnt"> ok? </SPAN>
</PRE>

<P><B>Notes from the April, 2017 teleconference:</B></P>

<P>Structured bindings have no C compatibility implications, so the
tag/nontag treatment need not apply.</P>

<P><B>Proposed resolution (February, 2019):</B></P>

<P>Change _N4868_.6.4.1 [<A href="https://wg21.link/basic.scope.declarative#4">basic.scope.declarative</A>] paragraph 4 as follows:</P>

<BLOCKQUOTE>

<P>Given a set of declarations in a single declarative region,
each of which specifies the same unqualified name,</P>

<UL>
<LI><P>they shall all refer to the same entity, or all refer to
functions and function templates; or</P></LI>

<LI><P>exactly one declaration shall declare a class name or
enumeration name that is not a typedef name and the other
declarations shall all refer to the same variable,
non-static data member, or enumerator, or all refer to
functions and function templates; in this case the class
name or enumeration name is hidden
(_N4868_.6.4.10 [<A href="https://wg21.link/basic.scope.hiding">basic.scope.hiding</A>]). [<I>Note:</I>
A <INS>structured binding (9.7 [<A href="https://wg21.link/dcl.struct.bind">dcl.struct.bind</A>]),</INS>
namespace name <INS>(9.9 [<A href="https://wg21.link/basic.namespace">basic.namespace</A>]),</INS>
or <DEL>a</DEL> class template
name <INS>(Clause 13 [<A href="https://wg21.link/temp">temp</A>])</INS> must be
unique in its declarative
region <DEL>(9.9.3 [<A href="https://wg21.link/namespace.alias">namespace.alias</A>],
Clause 13 [<A href="https://wg21.link/temp">temp</A>])</DEL>. &#8212;<I>end
note</I>]</P></LI>

</UL>

</BLOCKQUOTE>

<BR><BR>
</BODY>
</HTML>
