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

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

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

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

. . 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 T is any object type or the void type and where cv 1 ,k and cv 2 ,k may be different cv-qualifications,an rvalue of type T1 may be explicitly converted to the type T2 using a const_cast. The result of apointer const_cast refers to the original object.4An lvalue of type T1 can be explicitly converted to an lvalue of type T2 using the castconst_cast<T2&> (where T1 and T2 are object types) if a pointer to T1 can be explicitly converted tothe type pointer to T2 using a const_cast. The result of a reference const_cast refers to the original object.__________________65) The types may have different cv-qualifiers, subject to the overall restriction that a reinterpret_cast cannot cast away constness.66) T1 and T2 may have different cv-qualifiers, subject to the overall restriction that a reinterpret_cast cannot cast away constness.67) This is sometimes referred to as a type pun.74© ISO/IECISO/IEC 14882:1998(E)5 Expressions5.2.11 Const cast5For a const_cast involving pointers to data members, multi-level pointers to data members and multilevel mixed pointers and pointers to data members (4.4), the rules for const_cast are the same as thoseused for pointers; the “member” aspect of a pointer to member is ignored when determining where the cvqualifiers are added or removed by the const_cast.

The result of a pointer to data memberconst_cast refers to the same member as the original (uncast) pointer to data member.6A null pointer value (4.10) is converted to the null pointer value of the destination type. The null memberpointer value (4.11) is converted to the null member pointer value of the destination type.7[Note: Depending on the type of the object, a write operation through the pointer, lvalue or pointer to datamember resulting from a const_cast that casts away a const-qualifier68) may produce undefined behavior (7.1.5.1). ]8The following rules define the process known as casting away constness.

In these rules Tn and Xn represent types. For two pointer types:X 1 is T 1cv 1 , 1 * . . . cv 1 ,N *where T 1 is not a pointer type* . . . cv 2 ,M *where T 2 is not a pointer typeX 2 is T 2cv 2 , 1K is min(N,M)casting from X1 to X2 casts away constness if, for a non-pointer type T there does not exist an implicit conversion (clause 4) from:Tcv 1 , (N − K + 1 ) * cv 1 , (N − K + 2 ) * . .

. cv 1 ,N *toTcv 2 , (M − K + 1 ) * cv 2 , (M − K + 2 ) * . . . cv 2 ,M *9Casting from an lvalue of type T1 to an lvalue of type T2 using a reference cast casts away constness if acast from an rvalue of type “pointer to T1” to the type “pointer to T2” casts away constness.10Casting from 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” casts away constness if a cast from an rvalue of type “pointer to T1” to the type“pointer to T2” casts away constness.11For multi-level pointer to members and multi-level mixed pointers and pointer to members (4.4), the“member” aspect of a pointer to member level is ignored when determining if a const cv-qualifier hasbeen cast away.12[Note: some conversions which involve only changes in cv-qualification cannot be done usingconst_cast.

For instance, conversions between pointers to functions are not covered because suchconversions lead to values whose use causes undefined behavior. For the same reasons, conversionsbetween pointers to member functions, and in particular, the conversion from a pointer to a const memberfunction to a pointer to a non-const member function, are not covered. ]__________________68) const_cast is not limited to conversions that cast away a const-qualifier.75ISO/IEC 14882:1998(E)1© ISO/IEC5.2.11 Const cast5 Expressions5.3 Unary expressions[expr.unary]Expressions with unary operators group right-to-left.unary-expression:postfix-expression++ cast-expression-- cast-expressionunary-operator cast-expressionsizeof unary-expressionsizeof ( type-id )new-expressiondelete-expressionunary-operator: one of* & + -!~5.3.1 Unary operators[expr.unary.op]1The unary * operator performs indirection: the expression to which it is applied shall be a pointer to anobject type, or a pointer to a function type and the result is an lvalue referring to the object or function towhich the expression points.

If the type of the expression is “pointer to T,” the type of the result is “T.”[Note: a pointer to an incomplete type (other than cv void ) can be dereferenced. The lvalue thus obtainedcan be used in limited ways (to initialize a reference, for example); this lvalue must not be converted to anrvalue, see 4.1. ]2The result of the unary & operator is a pointer to its operand. The operand shall be an lvalue or a qualifiedid.

In the first case, if the type of the expression is “T,” the type of the result is “pointer to T.” In particular,the address of an object of type “cv T” is “pointer to cv T,” with the same cv-qualifiers. For a qualified-id,if the member is a static member of type “T”, the type of the result is plain “pointer to T.” If the member isa nonstatic member of class C of type T, the type of the result is “pointer to member of class C of typeT.” [Example:struct A { int i; };struct B : A { };... &B::i ...// has type int A::*—end example] [Note: a pointer to member formed from a mutable nonstatic data member (7.1.1) doesnot reflect the mutable specifier associated with the nonstatic data member.

]3A pointer to member is only formed when an explicit & is used and its operand is a qualified-id notenclosed in parentheses. [Note: that is, the expression &(qualified-id), where the qualified-id isenclosed in parentheses, does not form an expression of type “pointer to member.” Neither doesqualified-id, because there is no implicit conversion from a qualified-id for a nonstatic member function to the type “pointer to member function” as there is from an lvalue of function type to the type “pointerto function” (4.3).

Nor is &unqualified-id a pointer to member, even within the scope of theunqualified-id’s class. ]4The address of an object of incomplete type can be taken, but if the complete type of that object is a classtype that declares operator&() as a member function, then the behavior is undefined (and no diagnosticis required). The operand of & shall not be a bit-field.5The address of an overloaded function (clause 13) can be taken only in a context that uniquely determineswhich version of the overloaded function is referred to (see 13.4). [Note: since the context might determinewhether the operand is a static or nonstatic member function, the context can also affect whether the expression has type “pointer to function” or “pointer to member function.” ]6The operand of the unary + operator shall have arithmetic, enumeration, or pointer type and the result is thevalue of the argument.

Integral promotion is performed on integral or enumeration operands. The type ofthe result is the type of the promoted operand.76© ISO/IEC5 ExpressionsISO/IEC 14882:1998(E)5.3.1 Unary operators7The operand of the unary - operator shall have arithmetic or enumeration type and the result is the negationof its operand.

Integral promotion is performed on integral or enumeration operands. The negative of anunsigned quantity is computed by subtracting its value from 2 n , where n is the number of bits in the promoted operand. The type of the result is the type of the promoted operand.8The operand of the logical negation operator ! is implicitly converted to bool (clause 4); its value istrue if the converted operand is false and false otherwise. The type of the result is bool.9The operand of ~ shall have integral or enumeration type; the result is the one’s complement of its operand.Integral promotions are performed.

The type of the result is the type of the promoted operand. There is anambiguity in the unary-expression ~X(), where X is a class-name. The ambiguity is resolved in favor oftreating ~ as a unary complement rather than treating ~X as referring to a destructor.5.3.2 Increment and decrement[expr.pre.incr]1The operand of prefix ++ is modified by adding 1, or set to true if it is bool (this use is deprecated).The operand shall be a modifiable lvalue. The type of the operand shall be an arithmetic type or a pointerto a completely-defined object type.

The value is the new value of the operand; it is an lvalue. If x is notof type bool, the expression ++x is equivalent to x+=1. [Note: see the discussions of addition (5.7) andassignment operators (5.17) for information on conversions. ]2The operand of prefix -- is modified by subtracting 1. The operand shall not be of type bool. Therequirements on the operand of prefix -- and the properties of its result are otherwise the same as those ofprefix ++.

[Note: For postfix increment and decrement, see 5.2.6. ]5.3.3 Sizeof[expr.sizeof]1The sizeof operator yields the number of bytes in the object representation of its operand. The operandis either an expression, which is not evaluated, or a parenthesized type-id. The sizeof operator shall notbe applied to an expression that has function or incomplete type, or to an enumeration type before all itsenumerators have been declared, or to the parenthesized name of such types, or to an lvalue that designatesa bit-field.

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

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

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

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