On 10/23/2012 7:39 AM, Ivan Sorokin wrote:
> struct g
> {
> template <typename T>
> struct z;
> };
>
> template <typename T>
> struct x
> {
> typedef g y;
> };
>
> template <typename T>
> struct x<T>:
:z
> {
> int b;
> };
>
> The code above is accepted by all major compilers. I wonder if this
> code is correct. I haven't found any relevant information in the
> standard.
The code above is OK syntactically. The problem with it (if any) will
only be exposed when you try to instantiate either x<> or g::z<>. Let's
see the code that actually *uses* those templates.
> Is this code correct? What is the general rule about how a name
> qualifier in out of line class definition should be treated?
Every template-id has to have the template arguments follow it unless
they are implicit. I don't see anything implicit here. x<T> and
g::z<T> are two unrelated templates AFAICT. So, my conclusion is that
the use 'z' in the definition of x:

:z requires the template argument
just like the use of 'x' would. Until you try to use 'x' or
'x<whatever>:

:z', you won't know where (or whether) you have made a
mistake.
V
--
I do not respond to top-posted replies, please don't ask