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

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

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

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

The effect of such an explicit conversion is the same as performing the declaration and initialization and then using the temporary variable as the result of the conversion. The result is an lvalue if T is areference type (8.3.2), and an rvalue otherwise. The expression e is used as an lvalue if and only if theinitialization uses it as an lvalue.3Otherwise, the static_cast shall perform one of the conversions listed below. No other conversionshall be performed explicitly using a static_cast.4Any expression can be explicitly converted to type “cv void.” The expression value is discarded.

[Note:however, if the value is in a temporary variable (12.2), the destructor for that variable is not executed untilthe usual time, and the value of the variable is preserved for the purpose of executing the destructor. ] Thelvalue-to-rvalue (4.1), array-to-pointer (4.2), and function-to-pointer (4.3) standard conversions are notapplied to the expression.5An lvalue of type “cv1 B”, where B is a class type, can be cast to type “reference to cv2 D”, where D is aclass derived (clause 10) from B, if a valid standard conversion from “pointer to D” to “pointer to B” exists(4.10), cv2 is the same cv-qualification as, or greater cv-qualification than, cv1, and B is not a virtual baseclass of D. The result is an lvalue of type “cv2 D.” If the lvalue of type “cv1 B” is actually a sub-object ofan object of type D, the lvalue refers to the enclosing object of type D.

Otherwise, the result of the cast isundefined. [Example:struct B {};struct D : public B {};D d;B &br = d;static_cast<D&>(br);// produces lvalue to the original d object—end example]6The inverse of any standard conversion sequence (clause 4), other than the lvalue-to-rvalue (4.1), array-topointer (4.2), function-to-pointer (4.3), and boolean (4.12) conversions, can be performed explicitly usingstatic_cast subject to the restriction that the explicit conversion does not cast away constness (5.2.11),and the following additional rules for specific cases:72© ISO/IEC5 ExpressionsISO/IEC 14882:1998(E)5.2.9 Static cast7A value of integral type can be explicitly converted to an enumeration type.

The value is unchanged if theintegral value is within the range of the enumeration values (7.2). Otherwise, the resulting enumerationvalue is unspecified.8An rvalue of type “pointer to cv1 B”, where B is a class type, can be converted to an rvalue of type “pointerto cv2 D”, where D is a class derived (clause 10) from B, if a valid standard conversion from “pointer to D”to “pointer to B” exists (4.10), cv2 is the same cv-qualification as, or greater cv-qualification than, cv1, andB is not a virtual base class of D. The null pointer value (4.10) is converted to the null pointer value of thedestination type. If the rvalue of type “pointer to cv1 B” points to a B that is actually a sub-object of anobject of type D, the resulting pointer points to the enclosing object of type D.

Otherwise, the result of thecast is undefined.9An rvalue of type “pointer to member of D of type cv1 T” can be converted to an rvalue of type “pointer tomember of B of type cv2 T”, where B is a base class (clause 10) of D, if a valid standard conversion from“pointer to member of B of type T” to “pointer to member of D of type T” exists (4.11), and cv2 is the samecv-qualification as, or greater cv-qualification than, cv1.63) The null member pointer value (4.11) is converted to the null member pointer value of the destination type. If class B contains the original member, oris a base or derived class of the class containing the original member, the resulting pointer to memberpoints to the original member.

Otherwise, the result of the cast is undefined. [Note: although class B neednot contain the original member, the dynamic type of the object on which the pointer to member is dereferenced must contain the original member; see 5.5. ]10An rvalue of type “pointer to cv void” can be explicitly converted to a pointer to object type.

A value oftype pointer to object converted to “pointer to cv void” and back to the original pointer type will have itsoriginal value.5.2.10 Reinterpret cast[expr.reinterpret.cast]1The result of the expression reinterpret_cast<T>(v) is the result of converting the expression v totype T. If T is a reference type, the result is an lvalue; otherwise, the result is an rvalue and the lvalue-torvalue (4.1), array-to-pointer (4.2), and function-to-pointer (4.3) standard conversions are performed on thethe expression v. Types shall not be defined in a reinterpret_cast.

Conversions that can be performed explicitly using reinterpret_cast are listed below. No other conversion can be performedexplicitly using reinterpret_cast.2The reinterpret_cast operator shall not cast away constness. [Note: see 5.2.11 for the definition of‘‘casting away constness’’. Subject to the restrictions in this section, an expression may be cast to its owntype using a reinterpret_cast operator. ]3The mapping performed by reinterpret_cast is implementation-defined.

[Note: it might, or mightnot, produce a representation different from the original value. ]4A pointer can be explicitly converted to any integral type large enough to hold it. The mapping function isimplementation-defined [Note: it is intended to be unsurprising to those who know the addressing structureof the underlying machine. ]5A value of integral type or enumeration type can be explicitly converted to a pointer.64) A pointer convertedto an integer of sufficient size (if any such exists on the implementation) and back to the same pointer typewill have its original value; mappings between pointers and integers are otherwise implementation-defined.6A pointer to a function can be explicitly converted to a pointer to a function of a different type.

The effectof calling a function through a pointer to a function type (8.3.5) that is not the same as the type used in thedefinition of the function is undefined. Except that converting an rvalue of type “pointer to T1” to the type“pointer to T2” (where T1 and T2 are function types) and back to its original type yields the originalpointer value, the result of such a pointer conversion is unspecified. [Note: see also 4.10 for more details of__________________63) Function types (including those used in pointer to member function types) are never cv-qualified; see 8.3.5 .64) Converting an integral constant expression (5.19) with value zero always yields a null pointer (4.10), but converting other expressions that happen to have value zero need not yield a null pointer.73ISO/IEC 14882:1998(E)5.2.10 Reinterpret cast© ISO/IEC5 Expressionspointer conversions.

]7A pointer to an object can be explicitly converted to a pointer to an object of different type.65) Except thatconverting an rvalue of type “pointer to T1” to the type “pointer to T2” (where T1 and T2 are object typesand where the alignment requirements of T2 are no stricter than those of T1) and back to its original typeyields the original pointer value, the result of such a pointer conversion is unspecified.8The null pointer value (4.10) is converted to the null pointer value of the destination type.9An rvalue of type “pointer to member of X of type T1” can be explicitly converted to an rvalue of type“pointer to member of Y of type T2” if T1 and T2 are both function types or both object types.66) The nullmember pointer value (4.11) is converted to the null member pointer value of the destination type. Theresult of this conversion is unspecified, except in the following cases:— converting an rvalue of type “pointer to member function” to a different pointer to member functiontype and back to its original type yields the original pointer to member value.— converting an rvalue of type “pointer to data member of X of type T1” to the type “pointer to data member of Y of type T2” (where the alignment requirements of T2 are no stricter than those of T1) and backto its original type yields the original pointer to member value.10An lvalue expression of type T1 can be cast to the type “reference to T2” if an expression of type “pointerto T1” can be explicitly converted to the type “pointer to T2” using a reinterpret_cast.

That is, areference cast reinterpret_cast<T&>(x) has the same effect as the conversion*reinterpret_cast<T*>(&x) with the built-in & and * operators. The result is an lvalue that refersto the same object as the source lvalue, but with a different type. No temporary is created, no copy is made,and constructors (12.1) or conversion functions (12.3) are not called.67)5.2.11 Const cast[expr.const.cast]1The result of the expression const_cast<T>(v) is of type T. If T is a reference type, the result is anlvalue; otherwise, the result is an rvalue and, the lvalue-to-rvalue (4.1), array-to-pointer (4.2), andfunction-to-pointer (4.3) standard conversions are performed on the expression v. Types shall not bedefined in a const_cast.

Conversions that can be performed explicitly using const_cast are listedbelow. No other conversion shall be performed explicitly using const_cast.2[Note: Subject to the restrictions in this section, an expression may be cast to its own type using aconst_cast operator. ]3For two pointer types T1 and T2 whereT1 is cv 1 , 0 pointer to cv 1 , 1 pointer to .

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

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

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

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