Topic: Ambiguity resolution with "class Foo" and template-arguments


Author: "Johannes Schaub (litb)" <schaub-johannes@web.de>
Date: Mon, 14 Dec 2009 11:40:28 CST
Raw View
Hello all. There are two ambiguities that i can't find a resolution to. The
first, which the note in 14.2/3 explains is:

template<class T> void f();

The note says "because of the name lookup rules, a template-parameter that
could be interpreted as either a non-type template-parameter or a type-
parameter (because its identifier is the name of an already existing class)
is taken as a type-parameter.". What does it mean by these "name lookup
rules"? Why isn't it parsed as an elaborated-type-specifier in a parameter-
declaration which introduces "T" as a new class-name if it doesn't exist
yet, and uses the already existing "T" that lookup found?

The second question is:

int const i = 0;
template<int> struct F;
F<i> f;

In this, the grammar in n3000 for "template-argument" contains both id-
expresssion and constant-expression as productions. What path to take? Is
there a paragraph that states this?

Thanks!

--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]