Re: Объявление (вопрос по стандарту C++)
От: _DAle_ Беларусь  
Дата: 19.03.06 13:03
Оценка:
Здравствуйте, Steel1.0, Вы писали:

S0>C++ Standard 2003 четко оговаривает лишь этот код, как некорректный:

S0>
S0>struct S { int x; };
S0>typedef S T;
S0>struct T* s;
S0>


S0>Является ли следующий пример кода корректным с тояки зрения стандарта?

S0>
S0>typedef int A;
S0>long A a;
S0>

S0>Места в стандарте, где этот пример четко оговаривается я так и не нашел. Например, компилятор Microsoft Visual Studio 2005 считает его ошибочным. Если не трудно, прошу указать место в стандарте, где этот случай прямо или косвенно поясняется.
S0>Заранее благодарен.



7.1.5/1
The type-specifiers are
type-specifier:
   simple-type-specifier
   class-specifier
   enum-specifier
   elaborated-type-specifier
   cv-qualifier

As a general rule, at most one type-specifier is allowed in the complete decl-specifier-seq of a declaration.
The only exceptions to this rule are the following:
  — const or volatile can be combined with any other type-specifier. However, redundant cvqualifiers are prohibited except when introduced through the use of typedefs (7.1.3) or template type arguments (14.3), in which case the redundant cv-qualifiers are ignored.
  — signed or unsigned can be combined with char, long, short, or int.
  — short or long can be combined with int.
  — long can be combined with double.

 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.