Template problem (from `iterator_traits')
Martin von Loewis
martin@mira.isdn.cs.tu-berlin.de
Sat Nov 7 03:49:00 GMT 1998
> I report the following problem but I have no idea whether it is bug in
> the code or in the compilers;
It is a bug in the code.
> std::iterator_traits<X::I>::value_type v = 10;
[...]
> I would expect the compiler look up `value_type' etc. in enclosing
> scopes, but KCC 3.3e (on HP-UX 10.20) gives:
No. This is a qualified access. [class.qual] says
>> If the nestedÃÂnameÃÂspecifier of a qualifiedÃÂid nominates a class,
>> the name specified after the nestedÃÂnameÃÂspecifier is looked up in
>> the scope of the class (10.2), except for the cases listed
>> below. The name shall represent one or more members of that class
>> or of one of its base classes (clause 10).
No word about enclosing scopes. Since value_type is not a member X::I,
the program is ill-formed.
The rule you are proposing means that
void printf(char*,...);
class X{
};
int main()
{
X::printf("Hello, world\n");
}
would be well-formed. In standard C++, it is not.
Regards,
Martin
More information about the Gcc-bugs
mailing list