Topic: Is ::typedef_name illegal? Why?
Author: fenster@ground.cs.columbia.edu (Sam Fenster)
Date: 1995/04/25 Raw View
Looking at the grammar in The C++ Programming Laguage, 2nd Ed., I notice
(r7.1.6, last para.) that a global typedef `T' can't be referred to as
`::T'. Why this nonorthogonality? How do I refer to global T in a scope that
has another T?
Author: clamage@Eng.Sun.COM (Steve Clamage)
Date: 1995/04/25 Raw View
In article 95Apr24233406@ground.cs.columbia.edu, fenster@ground.cs.columbia.edu (Sam Fenster) writes:
>Looking at the grammar in The C++ Programming Laguage, 2nd Ed., I notice
>(r7.1.6, last para.) that a global typedef `T' can't be referred to as
>`::T'. Why this nonorthogonality? How do I refer to global T in a scope that
>has another T?
You can use ::T, which has always been allowed.
The grammar in C++PL2 isn't always exactly right. In my copy, for example,
the grammar in r7.1.6 isn't the same as the same section in the grammar
summary in the back.
In the current version of the draft standard the corresponding section
looks like this:
type-specifier:
simple-type-specifier
class-specifier
enum-specifier
elaborated-type-specifier
cv-qualifier
simple-type-specifier:
::/opt nested-name-specifier/opt type-name
char
wchar_t
bool
short
int
long
signed
unsigned
float
double
void
type-name:
class-name
enum-name
typedef-name
---
Steve Clamage, stephen.clamage@eng.sun.com