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

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

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

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

The type ofthe result is that of the promoted left operand. The behavior is undefined if the right operand is negative, orgreater than or equal to the length in bits of the promoted left operand.2The value of E1 << E2 is E1 (interpreted as a bit pattern) left-shifted E2 bit positions; vacated bits arezero-filled. If E1 has an unsigned type, the value of the result is E1 multiplied by the quantity 2 raised tothe power E2, reduced modulo ULONG_MAX+1 if E1 has type unsigned long, UINT_MAX+1 otherwise.[Note: the constants ULONG_MAX and UINT_MAX are defined in the header <climits>). ]3The value of E1 >> E2 is E1 right-shifted E2 bit positions.

If E1 has an unsigned type or if E1 has asigned type and a nonnegative value, the value of the result is the integral part of the quotient of E1 dividedby the quantity 2 raised to the power E2. If E1 has a signed type and a negative value, the resulting valueis implementation-defined.5.9 Relational operators1[expr.rel]The relational operators group left-to-right.(a<b)&&(b<c). ]relational-expression:shift-expressionrelational-expressionrelational-expressionrelational-expressionrelational-expression[Example: a<b<cmeans(a<b)<candnot< shift-expression> shift-expression<= shift-expression>= shift-expressionThe operands shall have arithmetic, enumeration or pointer type.

The operators < (less than), > (greaterthan), <= (less than or equal to), and >= (greater than or equal to) all yield false or true. The type ofthe result is bool.__________________75) Another way to approach pointer arithmetic is first to convert the pointer(s) to character pointer(s): In this scheme the integral valueof the expression added to or subtracted from the converted pointer is first multiplied by the size of the object originally pointed to, andthe resulting pointer is converted back to the original type. For pointer subtraction, the result of the difference between the characterpointers is similarly divided by the size of the object originally pointed to.7When viewed in this way, an implementation need only provide one extra byte (which might overlap another object in the program)just after the end of the object in order to satisfy the “one past the last element” requirements.85ISO/IEC 14882:1998(E)© ISO/IEC5.9 Relational operators25 ExpressionsThe usual arithmetic conversions are performed on operands of arithmetic or enumeration type.

Pointerconversions (4.10) and qualification conversions (4.4) are performed on pointer operands (or on a pointeroperand and a null pointer constant) to bring them to their composite pointer type. If one operand is a nullpointer constant, the composite pointer type is the type of the other operand.

Otherwise, if one of theoperands has type “pointer to cv1 void”, then the other has type “pointer to cv2 T” and the compositepointer type is “pointer to cv12 void”, where cv12 is the union of cv1 and cv2. Otherwise, the compositepointer type is a pointer type similar (4.4) to the type of one of the operands, with a cv-qualification signature (4.4) that is the union of the cv-qualification signatures of the operand types. [Note: this implies thatany pointer can be compared to a null pointer constant and that any object pointer can be compared to apointer to (possibly cv-qualified) void.

] [Example:void *p;const int *q;int **pi;const int *const *pci;void ct(){p <= q;pi <= pci;}// Both converted to const void * before comparison// Both converted to const int *const * before comparison—end example] Pointers to objects or functions of the same type (after pointer conversions) can be compared, with a result defined as follows:— If two pointers p and q of the same type point to the same object or function, or both point one past theend of the same array, or are both null, then p<=q and p>=q both yield true and p<q and p>q bothyield false.— If two pointers p and q of the same type point to different objects that are not members of the sameobject or elements of the same array or to different functions, or if only one of them is null, the resultsof p<q, p>q, p<=q, and p>=q are unspecified.— If two pointers point to nonstatic data members of the same object, or to subobjects or array elements ofsuch members, recursively, the pointer to the later declared member compares greater provided the twomembers are not separated by an access-specifier label (11.1) and provided their class is not a union.— If two pointers point to nonstatic data members of the same object separated by an access-specifier label(11.1) the result is unspecified.— If two pointers point to data members of the same union object, they compare equal (after conversion tovoid*, if necessary).

If two pointers point to elements of the same array or one beyond the end of thearray, the pointer to the object with the higher subscript compares higher.— Other pointer comparisons are unspecified.5.10 Equality operators[expr.eq]equality-expression:relational-expressionequality-expression == relational-expressionequality-expression != relational-expression1The == (equal to) and the != (not equal to) operators have the same semantic restrictions, conversions, andresult type as the relational operators except for their lower precedence and truth-value result. [Note: a<b== c<d is true whenever a<b and c<d have the same truth-value. ] Pointers to objects or functions ofthe same type (after pointer conversions) can be compared for equality. Two pointers of the same typecompare equal if and only if they are both null, both point to the same object or function, or both point onepast the end of the same array.86© ISO/IECISO/IEC 14882:1998(E)5 Expressions25.10 Equality operatorsIn addition, pointers to members can be compared, or a pointer to member and a null pointer constant.Pointer to member conversions (4.11) and qualification conversions (4.4) are performed to bring them to acommon type.

If one operand is a null pointer constant, the common type is the type of the other operand.Otherwise, the common type is a pointer to member type similar (4.4) to the type of one of the operands,with a cv-qualification signature (4.4) that is the union of the cv-qualification signatures of the operandtypes. [Note: this implies that any pointer to member can be compared to a null pointer constant. ] If bothoperands are null, they compare equal. Otherwise if only one is null, they compare unequal. Otherwise ifeither is a pointer to a virtual member function, the result is unspecified. Otherwise they compare equal ifand only if they would refer to the same member of the same most derived object (1.8) or the same subobject if they were dereferenced with a hypothetical object of the associated class type.

[Example:struct B {int f();};struct L : B { };struct R : B { };struct D : L, R { };int (B::*pb)() = &B::f;int (L::*pl)() = pb;int (R::*pr)() = pb;int (D::*pdl)() = pl;int (D::*pdr)() = pr;bool x = (pdl == pdr);// false—end example]5.11 Bitwise AND operator[expr.bit.and]and-expression:equality-expressionand-expression & equality-expression1The usual arithmetic conversions are performed; the result is the bitwise AND function of the operands. Theoperator applies only to integral or enumeration operands.5.12 Bitwise exclusive OR operator[expr.xor]exclusive-or-expression:and-expressionexclusive-or-expression ^ and-expression1The usual arithmetic conversions are performed; the result is the bitwise exclusiveoperands.

The operator applies only to integral or enumeration operands.OR5.13 Bitwise inclusive OR operatorfunction of the[expr.or]inclusive-or-expression:exclusive-or-expressioninclusive-or-expression | exclusive-or-expression1The usual arithmetic conversions are performed; the result is the bitwise inclusiveoperands. The operator applies only to integral or enumeration operands.5.14 Logical AND operatorORfunction of its[expr.log.and]logical-and-expression:inclusive-or-expressionlogical-and-expression && inclusive-or-expression87ISO/IEC 14882:1998(E)© ISO/IEC5.14 Logical AND operator5 Expressions1The && operator groups left-to-right. The operands are both implicitly converted to type bool (clause 4).The result is true if both operands are true and false otherwise. Unlike &, && guarantees left-to-rightevaluation: the second operand is not evaluated if the first operand is false.2The result is a bool.

All side effects of the first expression except for destruction of temporaries (12.2)happen before the second expression is evaluated.5.15 Logical OR operator[expr.log.or]logical-or-expression:logical-and-expressionlogical-or-expression || logical-and-expression1The || operator groups left-to-right. The operands are both implicitly converted to bool (clause 4). Itreturns true if either of its operands is true, and false otherwise. Unlike |, || guarantees left-toright evaluation; moreover, the second operand is not evaluated if the first operand evaluates to true.2The result is a bool.

All side effects of the first expression except for destruction of temporaries (12.2)happen before the second expression is evaluated.5.16 Conditional operator[expr.cond]conditional-expression:logical-or-expressionlogical-or-expression ? expression : assignment-expression1Conditional expressions group right-to-left. The first expression is implicitly converted to bool (clause 4).It is evaluated and if it is true, the result of the conditional expression is the value of the second expression, otherwise that of the third expression. All side effects of the first expression except for destruction oftemporaries (12.2) happen before the second or third expression is evaluated.

Only one of the second andthird expressions is evaluated.2If either the second or the third operand has type (possibly cv-qualified) void, then the lvalue-to-rvalue(4.1), array-to-pointer (4.2), and function-to-pointer (4.3) standard conversions are performed on the secondand third operands, and one of the following shall hold:— The second or the third operand (but not both) is a throw-expression (15.1); the result is of the type ofthe other and is an rvalue.— Both the second and the third operands have type void; the result is of type void and is an rvalue.[Note: this includes the case where both operands are throw-expressions. ]3Otherwise, if the second and third operand have different types, and either has (possibly cv-qualified) classtype, an attempt is made to convert each of those operands to the type of the other.

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

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

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

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