<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 159</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="159"></A><H4>159.
  
Namespace qualification in declarators
</H4>
<B>Section: </B>9.3.4&#160; [<A href="https://wg21.link/dcl.meaning">dcl.meaning</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>John Spicer
 &#160;&#160;&#160;

 <B>Date: </B>23 Aug 1999<BR>



<P>9.3.4 [<A href="https://wg21.link/dcl.meaning#1">dcl.meaning</A>] paragraph 1
says:</P>

<BLOCKQUOTE>
In the qualified <I>declarator-id</I> for a class or namespace member
definition that appears outside of the member's class or namespace,
the <I>nested-name-specifier</I> shall not name any of the namespaces that
enclose the member's definition.
</BLOCKQUOTE>

This results in the following behavior:

<PRE>
    namespace N {
        namespace M {
            void f();
            void g();
        }
        void M::f(){}     // okay
        void N::M::g(){}  // error
    }
</PRE>

I was very surprised when this rule was pointed out to me.  The change
appears to have been introduced around the time of the first Santa
Cruz meeting, but I don't recall discussion of it and could not find a
motion related to it.

<P>Regardless of where it came from, I also can't understand why it is there.
Certainly it shouldn't matter <I>how</I> you name a given class or namespace.</P>

<P>For example, the standard permits:</P>

<PRE>
    namespace N {
        namespace M {
            void f();
            void g();
        }
        namespace X = M;
        namespace Y = N::M;
        void X::f(){}  // okay
        void Y::g(){}  // okay
    }
</PRE>

So, it is okay to use an alias for <TT>N::M</TT>,
but not to use <TT>N::M</TT> directly.
Note that it <I>is</I> okay to use <TT>N::M</TT>
in any other context at this point
in the program (i.e., the rule is a specific restriction on declarator
names, not a general rule on the use of qualified names).

<P>Does anyone recall the intent of this rule or any rationale for its
existence?</P>

<P><B>Notes from 04/00 meeting:</B></P>

<P>There was some question as to whether this issue actually
constituted a defect in the Standard.  John Spicer suggested that
machine-generated source code would be likely to run afoul of this
prohibition.  Francis Glassborow expressed support for a rule that
would allow full qualification, or qualification relative to the
namespace containing the definition, but not qualification relative to
a containing namespace.  There was no consensus for moving forward
with a DR at this point, so the issue was left in "review" status.</P>

<P><B>Proposed resolution (10/00):</B></P>

<P>Remove the last sentence of
9.3.4 [<A href="https://wg21.link/dcl.meaning#1">dcl.meaning</A>] paragraph 1 (cited above) and the example
that follows.</P>

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