7.1.5.2 简单类型说明符
7.1.5 .2 简单类型说明符
1、简单类型声明符为
simple-type-specifier:
::opt nested-name-specifieropt type-name
::opt nested-name-specifier template template-id
(此处的template应该是可选的,因为定义std::list<int> l;和std::template list<int> l;都是合法的)
char
wchar_t
bool
short
int
long
signed
unsigned
float
double
void
type-name:
class-name
enum-name
typedef-name
简单类型说明符或者说明一个先前声明的用户定义类型或者说明一种基本类型(
表7 简单类型说明符和它们所说明的类型
说明符 |
类型 |
type-name char unsigned char signed char bool unsigned unsigned int signed signed int int unsigned short int unsigned short unsigned long int unsigned long signed long int signed long long int long signed short int signed short short int short wchar_t float double long double void |
the type named "char" "unsigned char" "signed char" "bool" "unsigned int" "unsigned int" "int" "int" "int" "unsigned short int" "unsigned short int" "unsigned long int" "unsigned long int" "long int" "long int" "long int" "long int" "short int" "short int" "short int" "short int" "wchar_t" "float" "double" "long double" "void" |
在允许使用多个简单类型说明符的情况下(如unsigned long int使用了unsigned,long和int三个简单类型说明符),它们可以和其它的声明说明符(如typedef, const等)以任何顺序自由混合。例如:unsigned const long int, const unsigned long int, unsigned long int const等都是合法的。位域和char类型对象被表示为有符号还是无符号形式是由具体实现定义的。singed说明符用于强制char对象和位域为有符号形式;对于其它整型singed是冗余的(如signed int中的signed是冗余的)。