<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1838</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="1838"></A><H4>1838.
  
Definition via <I>unqualified-id</I> and <I>using-declaration</I>
</H4>
<B>Section: </B>_N4868_.9.8.2.3&#160; [<A href="https://wg21.link/namespace.memdef">namespace.memdef</A>]
 &#160;&#160;&#160;

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

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

 <B>Date: </B>2014-01-17<BR>


<P>[Moved to DR at the November, 2014 meeting.]</P>



<P>The Standard is not clear about what happens when an entity is
declared but not defined in an inner namespace and declared via a
<I>using-declaration</I> in an outer namespace, and a definition of an
entity with that name as an <I>unqualified-id</I> appears in the outer
namespace.  Is this a legitimate definition of the inner-namespace entity,
as it would be if the definition used a <I>qualified-id</I>, or is the
definition a member of the outer namespace and thus in conflict with
the <I>using-declaration</I>?  There is implementation divergence on
the treatment of such definitions.</P>

<P>See also issues <A HREF="1708.html">1708</A> and
<A HREF="1021.html">1021</A>.</P>

<P><B>Notes from the February, 2014 meeting:</B></P>

<P>CWG agreed that the definition in such cases is a member of the
outer namespace, not a redeclaration of the name introduced in that
namespace by the <I>using-declaration</I>.</P>

<P><B>Proposed Resolution (July, 2014):</B></P>

<OL>
<LI><P>Change _N4868_.9.8.2.3 [<A href="https://wg21.link/namespace.memdef#1">namespace.memdef</A>] paragraph 1 as follows:</P></LI>

<BLOCKQUOTE>

<P>
<DEL>Members (including explicit specializations of templates
(13.9.4 [<A href="https://wg21.link/temp.expl.spec">temp.expl.spec</A>])) of a namespace can be defined
within that namespace.</DEL> <INS>A declaration in a namespace
<TT>N</TT> (excluding declarations in nested scopes) whose
<I>declarator-id</I> is an <I>unqualified-id</I> declares (or
redeclares) a member of <TT>N</TT>, and may be a definition.
[<I>Note:</I> An explicit instantiation (13.9.3 [<A href="https://wg21.link/temp.explicit">temp.explicit</A>])
or explicit specialization (13.9.4 [<A href="https://wg21.link/temp.expl.spec">temp.expl.spec</A>]) of a
template does not introduce a name and thus may be declared
using an <I>unqualified-id</I> in a member of the enclosing
namespace set, if the primary template is declared in an inline
namespace. &#8212;<I>end note</I>]</INS> [<I>Example:</I>
</P>

<PRE>
  namespace X {
    void f() { /* ... */ }  <INS>//<SPAN CLASS="cmnt"> OK: introduces </SPAN>X::f()

    namespace M {
      void g();             //<SPAN CLASS="cmnt"> OK: introduces </SPAN>X::M::g()
    }
    using M::g;
    void g();               //<SPAN CLASS="cmnt"> error: conflicts with </SPAN>X::M::g()</INS>
  }
</PRE>

<P>&#8212;<I>end example</I>]</P>

</BLOCKQUOTE>

<LI><P>Change _N4868_.9.8.2.3 [<A href="https://wg21.link/namespace.memdef#3">namespace.memdef</A>] paragraph 3 as follows:</P></LI>

<BLOCKQUOTE>

<DEL>Every name first declared in a namespace is a member of that
namespace.</DEL> If a <TT>friend</TT> declaration...

</BLOCKQUOTE>

</OL>

<P>This resolution also resolves issues <A HREF="1021.html">1021</A>
and <A HREF="987.html">987</A>.</P>

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