7.1.5.3 详细类型说明符

7.1.5.3 详细类型说明符

elaborated-type-specifier:

class-key ::opt nested-name-specifieropt identifier

class-key ::opt nested-name-specifieropt templateopt template-id

enum ::opt nested-name-specifieropt identifier

typename ::opt nested-name-specifier identifier

typename ::opt nested-name-specifier templateopt template-id

1、只包含详细类型说明符的声明是非法的,除非是显式特化(14.7.3)、显式实例化或具有以下形式:

class-key identifier ;

friend class-key ::opt identifier ;

friend class-key ::opt template-id ;

friend class-key ::opt nested-name-specifier identifier ;

friend class-key ::opt nested-name-specifier templateopt template-id ;

23.4.4描述了名字查找过程是如何对详细类型说明符中的标识符进行查找的。如果标识符被解析为类名枚举名,那么同简单类型说明符引入类型名一样,详细类型说明符类名枚举名引入声明。如果标识符被解析为类型定义名或模板的类型参数,此详细类型说明符非法。[注:这意味着,在类型参数为T的类模板中,声明

friend class T;

是非法的] 如果名字查找过程未发现名字的声明,详细类型说明符是非法的,除非它具有class-key identifier的简单形式,在这种情况下,标识符3.3.1所描述的那样被声明。

3、出现在详细类型说明符中的类关键字和枚举关键字必须和详细类型说明符中的名字被声明的类型一致。这条规则也适用于声明类名或友元类的详细类型说明符形式,因为这种形式可被解释为对类定义的引用。因而,在任何详细类型说明符中,enum关键字必须被用于指向枚举类型(7.2),类关键字union必须被用于指向联合类型(第9章),类关键字classstruct必须被分别用于指向通过类关键字classstruct所声明的类(第9章)。

posted @ 2006-04-13 10:06  Goncely  阅读(255)  评论(0编辑  收藏  举报