Студопедия
Случайная страница | ТОМ-1 | ТОМ-2 | ТОМ-3
АрхитектураБиологияГеографияДругоеИностранные языки
ИнформатикаИсторияКультураЛитератураМатематика
МедицинаМеханикаОбразованиеОхрана трудаПедагогика
ПолитикаПравоПрограммированиеПсихологияРелигия
СоциологияСпортСтроительствоФизикаФилософия
ФинансыХимияЭкологияЭкономикаЭлектроника

Namespace alias qualifiers

Local variable declarations | The switch statement | The for statement | The foreach statement | The goto statement | The throw statement | The try statement | The using statement | The yield statement | Using alias directives |


Читайте также:
  1. DX10 Anti Aliasing (сглаживание): Nvidia Inspector
  2. Namespace and type names
  3. Using alias directives
  4. Using namespace 21 страница
  5. Using namespace directives

The namespace alias qualifier:: makes it possible to guarantee that type name lookups are unaffected by the introduction of new types and members. The namespace alias qualifier always appears between two identifiers referred to as the left-hand and right-hand identifiers. Unlike the regular. qualifier, the left-hand identifier of the:: qualifier is looked up only as an extern or using alias.

A qualified-alias-member is defined as follows:

qualified-alias-member:
identifier:: identifier type-argument-listopt

A qualified-alias-member can be used as a namespace-or-type-name (§3.8) or as the left operand in a member-access (§7.6.4).

A qualified-alias-member has one of two forms:

· N::I<A1,..., AK>, where N and I represent identifiers, and <A1,..., AK> is a type argument list. (K is always at least one.)

· N::I, where N and I represent identifiers. (In this case, K is considered to be zero.)

Using this notation, the meaning of a qualified-alias-member is determined as follows:

· If N is the identifier global, then the global namespace is searched for I:

o If the global namespace contains a namespace named I and K is zero, then the qualified-alias-member refers to that namespace.

o Otherwise, if the global namespace contains a non-generic type named I and K is zero, then the qualified-alias-member refers to that type.

o Otherwise, if the global namespace contains a type named I that has K type parameters, then the qualified-alias-member refers to that type constructed with the given type arguments.

o Otherwise, the qualified-alias-member is undefined and a compile-time error occurs.

· Otherwise, starting with the namespace declaration (§9.2) immediately containing the qualified-alias-member (if any), continuing with each enclosing namespace declaration (if any), and ending with the compilation unit containing the qualified-alias-member, the following steps are evaluated until an entity is located:

o If the namespace declaration or compilation unit contains a using-alias-directive that associates N with a type, then the qualified-alias-member is undefined and a compile-time error occurs.

o Otherwise, if the namespace declaration or compilation unit contains an extern-alias-directive or using-alias-directive that associates N with a namespace, then:

· If the namespace associated with N contains a namespace named I and K is zero, then the qualified-alias-member refers to that namespace.

· Otherwise, if the namespace associated with N contains a non-generic type named I and K is zero, then the qualified-alias-member refers to that type.

· Otherwise, if the namespace associated with N contains a type named I that has K type parameters, then the qualified-alias-member refers to that type constructed with the given type arguments.

· Otherwise, the qualified-alias-member is undefined and a compile-time error occurs.

· Otherwise, the qualified-alias-member is undefined and a compile-time error occurs.

Note that using the namespace alias qualifier with an alias that references a type causes a compile-time error. Also note that if the identifier N is global, then lookup is performed in the global namespace, even if there is a using alias associating global with a type or namespace.


Дата добавления: 2015-11-16; просмотров: 59 | Нарушение авторских прав


<== предыдущая страница | следующая страница ==>
Using namespace directives| Class base specification

mybiblioteka.su - 2015-2024 год. (0.006 сек.)