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

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

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

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

] A standardconversion sequence will be applied to an expression if necessary to convert it to a required destinationtype.2[Note: expressions with a given type will be implicitly converted to other types in several contexts:— When used as operands of operators. The operator’s requirements for its operands dictate the destination type (clause 5).— When used in the condition of an if statement or iteration statement (6.4, 6.5). The destination type isbool.— When used in the expression of a switch statement. The destination type is integral (6.4).— When used as the source expression for an initialization (which includes use as an argument in a function call and use as the expression in a return statement).

The type of the entity being initialized is(generally) the destination type. See 8.5, 8.5.3.—end note]3An expression e can be implicitly converted to a type T if and only if the declaration “T t=e;” is wellformed, for some invented temporary variable t (8.5). The effect of the implicit conversion is the same asperforming the declaration and initialization and then using the temporary variable as the result of the conversion.

The result is an lvalue if T is a reference type (8.3.2), and an rvalue otherwise. The expression eis used as an lvalue if and only if the initialization uses it as an lvalue.4[Note: For user-defined types, user-defined conversions are considered as well; see 12.3. In general, animplicit conversion sequence (13.3.3.1) consists of a standard conversion sequence followed by a userdefined conversion followed by another standard conversion sequence.5There are some contexts where certain conversions are suppressed.

For example, the lvalue-to-rvalue conversion is not done on the operand of the unary & operator. Specific exceptions are given in the descriptions of those operators and contexts. ]4.1 Lvalue-to-rvalue conversion1[conv.lval]An lvalue (3.10) of a non-function, non-array type T can be converted to an rvalue. If T is an incompletetype, a program that necessitates this conversion is ill-formed. If the object to which the lvalue refers is notan object of type T and is not an object of a type derived from T, or if the object is uninitialized, a programthat necessitates this conversion has undefined behavior.

If T is a non-class type, the type of the rvalue isthe cv-unqualified version of T. Otherwise, the type of the rvalue is T. 49)__________________49) In C++ class rvalues can have cv-qualified types (because they are objects). This differs from ISO C, in which non-lvalues neverhave cv-qualified types.57ISO/IEC 14882:1998(E)4.1 Lvalue-to-rvalue conversion© ISO/IEC4 Standard conversions2The value contained in the object indicated by the lvalue is the rvalue result.

When an lvalue-to-rvalue conversion occurs within the operand of sizeof (5.3.3) the value contained in the referenced object is notaccessed, since that operator does not evaluate its operand.3[Note: See also 3.10. ]4.2 Array-to-pointer conversion[conv.array]1An lvalue or rvalue of type “array of N T” or “array of unknown bound of T” can be converted to an rvalueof type “pointer to T.” The result is a pointer to the first element of the array.2A string literal (2.13.4) that is not a wide string literal can be converted to an rvalue of type “pointer tochar”; a wide string literal can be converted to an rvalue of type “pointer to wchar_t”.

In either case,the result is a pointer to the first element of the array. This conversion is considered only when there is anexplicit appropriate pointer target type, and not when there is a general need to convert from an lvalue to anrvalue. [Note: this conversion is deprecated. See Annex D. ] For the purpose of ranking in overload resolution (13.3.3.1.1), this conversion is considered an array-to-pointer conversion followed by a qualificationconversion (4.4). [Example: "abc" is converted to “pointer to const char” as an array-to-pointer conversion, and then to “pointer to char” as a qualification conversion. ]4.3 Function-to-pointer conversion[conv.func]1An lvalue of function type T can be converted to an rvalue of type “pointer to T.” The result is a pointer tothe function.50)2[Note: See 13.4 for additional rules for the case where the function is overloaded.

]4.4 Qualification conversions[conv.qual]1An rvalue of type “pointer to cv1 T” can be converted to an rvalue of type “pointer to cv2 T” if “cv2 T” ismore cv-qualified than “cv1 T.”2An rvalue of type “pointer to member of X of type cv1 T” can be converted to an rvalue of type “pointer tomember of X of type cv2 T” if “cv2 T” is more cv-qualified than “cv1 T.”3[Note: Function types (including those used in pointer to member function types) are never cv-qualified(8.3.5). ]4A conversion can add cv-qualifiers at levels other than the first in multi-level pointers, subject to the following rules:51)Two pointer types T1 and T2 are similar if there exists a type T and integer n > 0 such that:T1 is cv 1 , 0 pointer to cv 1 , 1 pointer to .

. . cv 1 ,n − 1 pointer to cv 1 ,n TandT2 is cv 2 , 0 pointer to cv 2 , 1 pointer to . . . cv 2 ,n − 1 pointer to cv 2 ,n Twhere each cv i, j is const, volatile, const volatile, or nothing. The n-tuple of cv-qualifiersafter the first in a pointer type, e.g., cv 1 , 1 , cv 1 , 2 , . . . , cv 1 ,n in the pointer type T1, is called the cvqualification signature of the pointer type.

An expression of type T1 can be converted to type T2 if andonly if the following conditions are satisfied:— the pointer types are similar.— for every j > 0, if const is in cv 1 , j then const is in cv 2 , j , and similarly for volatile.— if the cv 1 , j and cv 2 , j are different, then const is in every cv 2 ,k for 0 < k < j.__________________50) This conversion never applies to nonstatic member functions because an lvalue that refers to a nonstatic member function cannot beobtained.51) These rules ensure that const-safety is preserved by the conversion.58© ISO/IECISO/IEC 14882:1998(E)4 Standard conversions4.4 Qualification conversions[Note: if a program could assign a pointer of type T** to a pointer of type const T** (that is, if line //1below was allowed), a program could inadvertently modify a const object (as it is done on line //2). Forexample,int main() {const char c = ’c’;char* pc;const char** pcc = &pc;//1: not allowed*pcc = &c;*pc = ’C’;//2: modifies a const object}—end note]5A multi-level pointer to member type, or a multi-level mixed pointer and pointer to member type has theform:cv 0 P 0 to cv 1 P 1 to .

. . cv n − 1 P n − 1 to cv n Twhere P i is either a pointer or pointer to member and where T is not a pointer type or pointer to membertype.6Two multi-level pointer to member types or two multi-level mixed pointer and pointer to member types T1and T2 are similar if there exists a type T and integer n > 0 such that:T1 is cv 1 , 0 P 0 to cv 1 , 1 P 1 to . . . cv 1 ,n − 1 P n − 1 to cv 1 ,n TandT2 is cv 2 , 0 P 0 to cv 2 , 1 P 1 to . . . cv 2 ,n − 1 P n − 1 to cv 2 ,n T7For similar multi-level pointer to member types and similar multi-level mixed pointer and pointer to member types, the rules for adding cv-qualifiers are the same as those used for similar pointer types.4.5 Integral promotions[conv.prom]1An rvalue of type char, signed char, unsigned char, short int, or unsigned shortint can be converted to an rvalue of type int if int can represent all the values of the source type; otherwise, the source rvalue can be converted to an rvalue of type unsigned int.2An rvalue of type wchar_t (3.9.1) or an enumeration type (7.2) can be converted to an rvalue of the firstof the following types that can represent all the values of its underlying type: int, unsigned int,long, or unsigned long.3An rvalue for an integral bit-field (9.6) can be converted to an rvalue of type int if int can represent allthe values of the bit-field; otherwise, it can be converted to unsigned int if unsigned int can represent all the values of the bit-field.

If the bit-field is larger yet, no integral promotion applies to it. If thebit-field has an enumerated type, it is treated as any other value of that type for promotion purposes.4An rvalue of type bool can be converted to an rvalue of type int, with false becoming zero and truebecoming one.5These conversions are called integral promotions.4.6 Floating point promotion[conv.fpprom]1An rvalue of type float can be converted to an rvalue of type double.

The value is unchanged.2This conversion is called floating point promotion.59ISO/IEC 14882:1998(E)4.7 Integral conversions4.7 Integral conversions© ISO/IEC4 Standard conversions[conv.integral]1An rvalue of an integer type can be converted to an rvalue of another integer type. An rvalue of an enumeration type can be converted to an rvalue of an integer type.2If the destination type is unsigned, the resulting value is the least unsigned integer congruent to the sourceinteger (modulo 2 n where n is the number of bits used to represent the unsigned type). [Note: In a two’scomplement representation, this conversion is conceptual and there is no change in the bit pattern (if thereis no truncation).

]3If the destination type is signed, the value is unchanged if it can be represented in the destination type (andbit-field width); otherwise, the value is implementation-defined.4If the destination type is bool, see 4.12. If the source type is bool, the value false is converted to zeroand the value true is converted to one.5The conversions allowed as integral promotions are excluded from the set of integral conversions.4.8 Floating point conversions[conv.double]1An rvalue of floating point type can be converted to an rvalue of another floating point type.

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

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

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

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