<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 666</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="666"></A><H4>666.
  
Dependent <I>qualified-id</I>s without the <TT>typename</TT> keyword
</H4>
<B>Section: </B>13.8&#160; [<A href="https://wg21.link/temp.res">temp.res</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>6 December 2007<BR>


<P>[Voted into the WP at the June, 2008 meeting.]</P>

<P>13.8 [<A href="https://wg21.link/temp.res">temp.res</A>] paragraphs 2 and 4 read,</P>

<BLOCKQUOTE>

<P>A name used in a template declaration or definition and that is
dependent on a <I>template-parameter</I> is assumed not to name a type unless
the applicable name lookup finds a type name or the name is qualified
by the keyword <I>typename</I>.</P>

<P>If a specialization of a template is instantiated for a set of
<I>template-argument</I>s such that the <I>qualified-id</I> prefixed
by <TT>typename</TT> does not denote a type, the specialization is
ill-formed.</P>

</BLOCKQUOTE>

<P>It is not clear whether this is intended to, or is sufficient to,
render a specialization ill-formed if a dependent <I>qualified-id</I>
that is <I>not</I> prefixed by <TT>typename</TT> actually <I>does</I>
denote a type.  For example,</P>

<PRE>
    int i;

    template &lt;class T&gt; void f() {
        T::x * i; //<SPAN CLASS="cmnt"> declaration or multiplication!?</SPAN>
    }

    struct Foo {
        typedef int x;
    };

    struct Bar {
        static int const x = 5;
    };

    int main() {
        f&lt;Bar&gt;(); //<SPAN CLASS="cmnt"> multiplication</SPAN>
        f&lt;Foo&gt;(); //<SPAN CLASS="cmnt"> declaration!</SPAN>
    }
</PRE>

<P>I think that the specialization for <TT>Foo</TT> should be
ill-formed.</P>

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

<P>Add the following after 13.8 [<A href="https://wg21.link/temp.res#5">temp.res</A>] paragraph 5:</P>

<BLOCKQUOTE>

<P>If, for a given set of template arguments, a specialization of a template
is instantiated that refers to a <I>qualified-id</I> that denotes a type,
and the <I>nested-name-specifier</I> of the <I>qualified-id</I> depends
on a template parameter, the <I>qualified-id</I> shall either be prefixed
by <TT>typename</TT> or shall be used in a context in which it implicitly
names a type as described above.  [<I>Example:</I>
</P>

<PRE>
    template &lt;class T&gt; void f(int i) {
      T::x * i;     //<SPAN CLASS="cmnt"> </SPAN>T::x<SPAN CLASS="cmnt"> must not be a type</SPAN>
    }

    struct Foo {
      typedef int x;
    };

    struct Bar {
      static int const x = 5;
    };

    int main() {
      f&lt;Bar&gt;(1);     //<SPAN CLASS="cmnt"> OK</SPAN>
      f&lt;Foo&gt;(1);     //<SPAN CLASS="cmnt"> error: </SPAN>Foo::x<SPAN CLASS="cmnt"> is a type</SPAN>
    }
</PRE>

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

</BLOCKQUOTE>

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