Главная » Просмотр файлов » Стандарт C++ 98

Стандарт C++ 98 (1119566), страница 62

Файл №1119566 Стандарт C++ 98 (Стандарт C++ 98) 62 страницаСтандарт C++ 98 (1119566) страница 622019-05-09СтудИзба
Просмтор этого файла доступен только зарегистрированным пользователям. Но у нас супер быстрая регистрация: достаточно только электронной почты!

Текст из файла (страница 62)

The sequence of conversions isan implicit conversion as defined in clause 4, which means it is governed by the rules for initialization of anobject or reference by a single expression (8.5, 8.5.3).2Implicit conversion sequences are concerned only with the type, cv-qualification, and lvalue-ness of theargument and how these are converted to match the corresponding properties of the parameter. Other properties, such as the lifetime, storage class, alignment, or accessibility of the argument and whether or not theargument is a bit-field are ignored.

So, although an implicit conversion sequence can be defined for a givenargument-parameter pair, the conversion from the argument to the parameter might still be ill-formed in thefinal analysis.3Except in the context of an initialization by user-defined conversion (13.3.1.4, 13.3.1.5), a well-formedimplicit conversion sequence is one of the following forms:— a standard conversion sequence (13.3.3.1.1),— a user-defined conversion sequence (13.3.3.1.2), or— an ellipsis conversion sequence (13.3.3.1.3).4In the context of an initialization by user-defined conversion (i.e., when considering the argument of auser-defined conversion function; see 13.3.1.4, 13.3.1.5), only standard conversion sequences and ellipsisconversion sequences are allowed.5For the case where the parameter type is a reference, see 13.3.3.1.4.6When the parameter type is not a reference, the implicit conversion sequence models a copy-initializationof the parameter from the argument expression.

The implicit conversion sequence is the one required toconvert the argument expression to an rvalue of the type of the parameter. [Note: when the parameter has aclass type, this is a conceptual conversion defined for the purposes of clause 13; the actual initialization isdefined in terms of constructors and is not a conversion. ] Any difference in top-level cv-qualification issubsumed by the initialization itself and does not constitute a conversion. [Example: a parameter of type Acan be initialized from an argument of type const A. The implicit conversion sequence for that case isthe identity sequence; it contains no “conversion” from const A to A.

] When the parameter has a classtype and the argument expression has the same type, the implicit conversion sequence is an identity221ISO/IEC 14882:1998(E)© ISO/IEC13.3.3.1 Implicit conversion sequences13 Overloadingconversion. When the parameter has a class type and the argument expression has a derived class type, theimplicit conversion sequence is a derived-to-base Conversion from the derived class to the base class.[Note: there is no such standard conversion; this derived-to-base Conversion exists only in the descriptionof implicit conversion sequences. ] A derived-to-base Conversion has Conversion rank (13.3.3.1.1).7In all contexts, when converting to the implicit object parameter or when converting to the left operand ofan assignment operation only standard conversion sequences that create no temporary object for the resultare allowed.8If no conversions are required to match an argument to a parameter type, the implicit conversion sequenceis the standard conversion sequence consisting of the identity conversion (13.3.3.1.1).9If no sequence of conversions can be found to convert an argument to a parameter type or the conversion isotherwise ill-formed, an implicit conversion sequence cannot be formed.10If several different sequences of conversions exist that each convert the argument to the parameter type, theimplicit conversion sequence associated with the parameter is defined to be the unique conversion sequencedesignated the ambiguous conversion sequence.

For the purpose of ranking implicit conversion sequencesas described in 13.3.3.2, the ambiguous conversion sequence is treated as a user-defined sequence that isindistinguishable from any other user-defined conversion sequence124). If a function that uses the ambiguous conversion sequence is selected as the best viable function, the call will be ill-formed because the conversion of one of the arguments in the call is ambiguous.11The three forms of implicit conversion sequences mentioned above are defined in the following subclauses.13.3.3.1.1 Standard conversion sequences[over.ics.scs]1Table 9 summarizes the conversions defined in clause 4 and partitions them into four disjoint categories:Lvalue Transformation, Qualification Adjustment, Promotion, and Conversion.

[Note: these categories areorthogonal with respect to lvalue-ness, cv-qualification, and data representation: the Lvalue Transformations do not change the cv-qualification or data representation of the type; the Qualification Adjustments donot change the lvalue-ness or data representation of the type; and the Promotions and Conversions do notchange the lvalue-ness or cv-qualification of the type. ]2[Note: As described in clause 4, a standard conversion sequence is either the Identity conversion by itself(that is, no conversion) or consists of one to three conversions from the other four categories. At most oneconversion from each category is allowed in a single standard conversion sequence.

If there are two ormore conversions in the sequence, the conversions are applied in the canonical order: LvalueTransformation, Promotion or Conversion, Qualification Adjustment. —end note]__________________124) The ambiguous conversion sequence is ranked with user-defined conversion sequences because multiple conversion sequences foran argument can exist only if they involve different user-defined conversions.

The ambiguous conversion sequence is indistinguishablefrom any other user-defined conversion sequence because it represents at least two user-defined conversion sequences, each with a different user-defined conversion, and any other user-defined conversion sequence must be indistinguishable from at least one of them.This rule prevents a function from becoming non-viable because of an ambiguous conversion sequence for one of its parameters. Consider this example,class B;class A {class B {class C {void f(A)void f(C)B b;f(b);A (B&); };operator A (); };C (B&); };{ }{ }// ambiguous because b -> C via constructor and// b → A via constructor or conversion function.If it were not for this rule, f(A) would be eliminated as a viable function for the call f(b) causing overload resolution to select f(C)as the function to call even though it is not clearly the best choice.

On the other hand, if an f(B) were to be declared then f(b)would resolve to that f(B) because the exact match with f(B) is better than any of the sequences required to match f(A).222© ISO/IECISO/IEC 14882:1998(E)13 Overloading313.3.3.1.1 Standard conversion sequencesEach conversion in Table 9 also has an associated rank (Exact Match, Promotion, or Conversion). Theseare used to rank standard conversion sequences (13.3.3.2). The rank of a conversion sequence is determined by considering the rank of each conversion in the sequence and the rank of any reference binding(13.3.3.1.4). If any of those has Conversion rank, the sequence has Conversion rank; otherwise, if any ofthose has Promotion rank, the sequence has Promotion rank; otherwise, the sequence has Exact Match rank.Table 9—conversions_______________________________________________________________________________________________________________________________________________________ Subclause ConversionCategoryRank_____________________________________________________________________________No conversions requiredIdentity_______________________________________________________________Lvalue-to-rvalue conversion4.1________________________________________ Lvalue Transformation  Exact Match Array-to-pointer conversion4.2_______________________________________________________________________________________________________Function-to-pointer conversion 4.3 Qualification conversions Qualification Adjustment 4.4____________________________________________________________________________Integral promotions4.5 Promotion ________________________________________Promotion____________________________________________________________________________Floating point promotion4.6Integral conversions4.7________________________________________Floating point conversions4.8________________________________________ Floating-integral conversions 4.9____________________________Conversion Conversion ____________Pointer conversions4.10____________________________________________________________________Pointer to member conversions4.11____________Boolean conversions4.12____________________________________________________________________________13.3.3.1.2 User-defined conversion sequences[over.ics.user]1A user-defined conversion sequence consists of an initial standard conversion sequence followed by auser-defined conversion (12.3) followed by a second standard conversion sequence.

If the user-definedconversion is specified by a constructor (12.3.1), the initial standard conversion sequence converts thesource type to the type required by the argument of the constructor. If the user-defined conversion is specified by a conversion function (12.3.2), the initial standard conversion sequence converts the source type tothe implicit object parameter of the conversion function.2The second standard conversion sequence converts the result of the user-defined conversion to the targettype for the sequence. Since an implicit conversion sequence is an initialization, the special rules forinitialization by user-defined conversion apply when selecting the best user-defined conversion for a userdefined conversion sequence (see 13.3.3 and 13.3.3.1).3If the user-defined conversion is specified by a template conversion function, the second standard conversion sequence must have exact match rank.4A conversion of an expression of class type to the same class type is given Exact Match rank, and a conversion of an expression of class type to a base class of that type is given Conversion rank, in spite of the factthat a copy constructor (i.e., a user-defined conversion function) is called for those cases.13.3.3.1.3 Ellipsis conversion sequences1[over.ics.ellipsis]An ellipsis conversion sequence occurs when an argument in a function call is matched with the ellipsisparameter specification of the function called.223ISO/IEC 14882:1998(E)© ISO/IEC13.3.3.1.4 Reference binding13 Overloading13.3.3.1.4 Reference binding1[over.ics.ref]When a parameter of reference type binds directly (8.5.3) to an argument expression, the implicit conversion sequence is the identity conversion, unless the argument expression has a type that is a derived class ofthe parameter type, in which case the implicit conversion sequence is a derived-to-base Conversion(13.3.3.1).

Характеристики

Тип файла
PDF-файл
Размер
2,05 Mb
Материал
Тип материала
Высшее учебное заведение

Список файлов учебной работы

Свежие статьи
Популярно сейчас
А знаете ли Вы, что из года в год задания практически не меняются? Математика, преподаваемая в учебных заведениях, никак не менялась минимум 30 лет. Найдите нужный учебный материал на СтудИзбе!
Ответы на популярные вопросы
Да! Наши авторы собирают и выкладывают те работы, которые сдаются в Вашем учебном заведении ежегодно и уже проверены преподавателями.
Да! У нас любой человек может выложить любую учебную работу и зарабатывать на её продажах! Но каждый учебный материал публикуется только после тщательной проверки администрацией.
Вернём деньги! А если быть более точными, то автору даётся немного времени на исправление, а если не исправит или выйдет время, то вернём деньги в полном объёме!
Да! На равне с готовыми студенческими работами у нас продаются услуги. Цены на услуги видны сразу, то есть Вам нужно только указать параметры и сразу можно оплачивать.
Отзывы студентов
Ставлю 10/10
Все нравится, очень удобный сайт, помогает в учебе. Кроме этого, можно заработать самому, выставляя готовые учебные материалы на продажу здесь. Рейтинги и отзывы на преподавателей очень помогают сориентироваться в начале нового семестра. Спасибо за такую функцию. Ставлю максимальную оценку.
Лучшая платформа для успешной сдачи сессии
Познакомился со СтудИзбой благодаря своему другу, очень нравится интерфейс, количество доступных файлов, цена, в общем, все прекрасно. Даже сам продаю какие-то свои работы.
Студизба ван лав ❤
Очень офигенный сайт для студентов. Много полезных учебных материалов. Пользуюсь студизбой с октября 2021 года. Серьёзных нареканий нет. Хотелось бы, что бы ввели подписочную модель и сделали материалы дешевле 300 рублей в рамках подписки бесплатными.
Отличный сайт
Лично меня всё устраивает - и покупка, и продажа; и цены, и возможность предпросмотра куска файла, и обилие бесплатных файлов (в подборках по авторам, читай, ВУЗам и факультетам). Есть определённые баги, но всё решаемо, да и администраторы реагируют в течение суток.
Маленький отзыв о большом помощнике!
Студизба спасает в те моменты, когда сроки горят, а работ накопилось достаточно. Довольно удобный сайт с простой навигацией и огромным количеством материалов.
Студ. Изба как крупнейший сборник работ для студентов
Тут дофига бывает всего полезного. Печально, что бывают предметы по которым даже одного бесплатного решения нет, но это скорее вопрос к студентам. В остальном всё здорово.
Спасательный островок
Если уже не успеваешь разобраться или застрял на каком-то задание поможет тебе быстро и недорого решить твою проблему.
Всё и так отлично
Всё очень удобно. Особенно круто, что есть система бонусов и можно выводить остатки денег. Очень много качественных бесплатных файлов.
Отзыв о системе "Студизба"
Отличная платформа для распространения работ, востребованных студентами. Хорошо налаженная и качественная работа сайта, огромная база заданий и аудитория.
Отличный помощник
Отличный сайт с кучей полезных файлов, позволяющий найти много методичек / учебников / отзывов о вузах и преподователях.
Отлично помогает студентам в любой момент для решения трудных и незамедлительных задач
Хотелось бы больше конкретной информации о преподавателях. А так в принципе хороший сайт, всегда им пользуюсь и ни разу не было желания прекратить. Хороший сайт для помощи студентам, удобный и приятный интерфейс. Из недостатков можно выделить только отсутствия небольшого количества файлов.
Спасибо за шикарный сайт
Великолепный сайт на котором студент за не большие деньги может найти помощь с дз, проектами курсовыми, лабораторными, а также узнать отзывы на преподавателей и бесплатно скачать пособия.
Популярные преподаватели
Добавляйте материалы
и зарабатывайте!
Продажи идут автоматически
6367
Авторов
на СтудИзбе
310
Средний доход
с одного платного файла
Обучение Подробнее