Re: Is it a g++-4.1 bug ?
I should add here that my previous answer is based on my
interpretation
of the wording given in the current valid C++ standard 14882-2003,
which
says in 14.6/3:
"A qualified-id that refers to a type and in which the nested-name-
specifier
depends on a template-parameter (14.6.2) shall be prefixed by the
keyword
typename to indicate that the qualified-id denotes a type, forming
an elaborated-type-specifier (7.1.5.3)."
It seems that this is not as clear as it should, because the current
draft
N2134 is already modified here and says:
"When a qualified-id is intended to refer to a type that is not a
member of
the current instantiation (14.6.2.1) and its nested-name-specifier
depends
on a template-parameter (14.6.2), it shall be prefixed by the keyword
typename, forming a typename-specifier.[..]"
where the new notion of current instantiation is explained in
14.6.2.1/1:
"In the definition of a class template, a nested class of a class
template, a member of a class template, or a member of a nested
class of a class template, a name refers to the current instantiation
if it is
- the injected-class-name (9) of the class template or nested
class,
- in the definition of a primary class template, the name of the
class template followed by the template argument list of the
primary template (as described below) enclosed in <>,
- in the definition of a nested class of a class template, the
name of the nested class referenced as a member of the
current instantiation, or
- in the definition of a partial specialization, the name of the
class template followed by the template argument list
of the partial specialization enclosed in <>."
I would be glad if someone could explain to me, how we
can be sure that we in the scope of a class if we are currently
describing a return type of a member, i.e. in the simplified
version of the OP's example:
template <typename T>
struct Outer {
template <typename U>
struct Inner {
Inner& self(); // OK: Inner is Inner<U>
};
};
template <typename T>
template <typename U>
Outer<T>::Inner<U>& // Inside the class scope?
Outer<T>::Inner<U>::self() {
return *this;
}
Thanks for clarification and
Greetings from Bremen,
Daniel Kr?gler
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]