Non-type Lookup

During a discussion about the validity of A::A (and the fact that you cannot pass explicit template parameters to a template constructor) it came up that although non-types are ignored in the lookup for a base-clause, the same is not true for typedef… even though clearly only types are to be expected in either case.

Observe:

But:

Stupid language.

Constructor template parameters

This discussion had come about from a debate over the technique displayed in the following example ("BARK" is a third-party preprocessor macro that outputs the signature of the function that it's in):

Using the template constructor in this way is valid because the template parameter is deduced to be int from the function argument 3.

Now, let's look at the case where the class itself is the template. The class's template parameters cannot be deduced from arguments to its constructor, alas (at least not until C++0x):

However you can, of course, specify the template class parameter explicitly:

You'd expect that specifying a template parameter explicitly is always valid, and that only when trying to rely on implicit deduction might things get a bit hairy.

But you actually can't specify a template constructor parameter explicitly at all. The interesting thing here is in GCC's diagnostic, which isn't quite what you might expect:

What is happening here is that any class A is brought into its own scope. So as a type, A::A is equivalent to A, as is A::A::A and A::A::A::A::A::A::A. GCC parses A::A<int>() as A&lt;int&gt;(), then attempts to construct a temporary of type A&lt;int&gt;, but class A isn't itself a template so this fails.

A lengthy debate ensued and it was concluded that GCC is erroneous here. Comeau in fact agrees with our ultimate interpretation of the standard, and allows this by correctly parsing A::A<int> as the constructor A&lt;int&gt; of class A… although it's still not possible to directly invoke the constructor.

I'm actually still not 100% clear on this, so please jump on the wagon in the post comments if you can shed some more light on the issue.