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

Стандарт C++ 11 (1119564), страница 40

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

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

If the dynamictype of E1 does not contain the member to which E2 refers, the behavior is undefined.5The restrictions on cv-qualification, and the manner in which the cv-qualifiers of the operands are combinedto produce the cv-qualifiers of the result, are the same as the rules for E1.E2 given in 5.2.5. [ Note: it is notpossible to use a pointer to member that refers to a mutable member to modify a const class object. Forexample,struct S {S() : i(0) { }mutable int i;};§ 5.5118© ISO/IEC 2011 – All rights reservedISO/IEC 14882:2011(E)void f(){const S cs;int S::* pm = &S::i;cs.*pm = 88;}// pm refers to mutable member S::i// ill-formed: cs is a const object— end note ]6If the result of .* or ->* is a function, then that result can be used only as the operand for the function calloperator ().

[ Example:(ptr_to_obj->*ptr_to_mfct)(10);calls the member function denoted by ptr_to_mfct for the object pointed to by ptr_to_obj. — endexample ] In a .* expression whose object expression is an rvalue, the program is ill-formed if the secondoperand is a pointer to member function with ref-qualifier &. In a .* expression whose object expression isan lvalue, the program is ill-formed if the second operand is a pointer to member function with ref-qualifier&&. The result of a .* expression whose second operand is a pointer to a data member is of the same valuecategory (3.10) as its first operand. The result of a .* expression whose second operand is a pointer to amember function is a prvalue.

If the second operand is the null pointer to member value (4.11), the behavioris undefined.5.61Multiplicative operators[expr.mul]The multiplicative operators *, /, and % group left-to-right.multiplicative-expression:pm-expressionmultiplicative-expression * pm-expressionmultiplicative-expression / pm-expressionmultiplicative-expression % pm-expression2The operands of * and / shall have arithmetic or unscoped enumeration type; the operands of % shall haveintegral or unscoped enumeration type. The usual arithmetic conversions are performed on the operandsand determine the type of the result.3The binary * operator indicates multiplication.4The binary / operator yields the quotient, and the binary % operator yields the remainder from the divisionof the first expression by the second. If the second operand of / or % is zero the behavior is undefined.

Forintegral operands the / operator yields the algebraic quotient with any fractional part discarded;81 if thequotient a/b is representable in the type of the result, (a/b)*b + a%b is equal to a.5.71Additive operators[expr.add]The additive operators + and - group left-to-right. The usual arithmetic conversions are performed foroperands of arithmetic or enumeration type.additive-expression:multiplicative-expressionadditive-expression + multiplicative-expressionadditive-expression - multiplicative-expressionFor addition, either both operands shall have arithmetic or unscoped enumeration type, or one operand shallbe a pointer to a completely-defined object type and the other shall have integral or unscoped enumerationtype.81) This is often called truncation towards zero.§ 5.7© ISO/IEC 2011 – All rights reserved119ISO/IEC 14882:2011(E)2For subtraction, one of the following shall hold:— both operands have arithmetic or unscoped enumeration type; or— both operands are pointers to cv-qualified or cv-unqualified versions of the same completely-definedobject type; or— the left operand is a pointer to a completely-defined object type and the right operand has integral orunscoped enumeration type.3The result of the binary + operator is the sum of the operands.

The result of the binary - operator is thedifference resulting from the subtraction of the second operand from the first.4For the purposes of these operators, a pointer to a nonarray object behaves the same as a pointer to thefirst element of an array of length one with the type of the object as its element type.5When an expression that has integral type is added to or subtracted from a pointer, the result has the typeof the pointer operand.

If the pointer operand points to an element of an array object, and the array islarge enough, the result points to an element offset from the original element such that the difference ofthe subscripts of the resulting and original array elements equals the integral expression. In other words, ifthe expression P points to the i-th element of an array object, the expressions (P)+N (equivalently, N+(P))and (P)-N (where N has the value n) point to, respectively, the i + n-th and i − n-th elements of the arrayobject, provided they exist. Moreover, if the expression P points to the last element of an array object,the expression (P)+1 points one past the last element of the array object, and if the expression Q pointsone past the last element of an array object, the expression (Q)-1 points to the last element of the arrayobject.

If both the pointer operand and the result point to elements of the same array object, or one pastthe last element of the array object, the evaluation shall not produce an overflow; otherwise, the behavior isundefined.6When two pointers to elements of the same array object are subtracted, the result is the difference of thesubscripts of the two array elements.

The type of the result is an implementation-defined signed integraltype; this type shall be the same type that is defined as std::ptrdiff_t in the <cstddef> header (18.2). Aswith any other arithmetic overflow, if the result does not fit in the space provided, the behavior is undefined.In other words, if the expressions P and Q point to, respectively, the i-th and j-th elements of an array object,the expression (P)-(Q) has the value i − j provided the value fits in an object of type std::ptrdiff_t.Moreover, if the expression P points either to an element of an array object or one past the last element ofan array object, and the expression Q points to the last element of the same array object, the expression((Q)+1)-(P) has the same value as ((Q)-(P))+1 and as -((P)-((Q)+1)), and has the value zero if theexpression P points one past the last element of the array object, even though the expression (Q)+1 does notpoint to an element of the array object.

Unless both pointers point to elements of the same array object, orone past the last element of the array object, the behavior is undefined.827If the value 0 is added to or subtracted from a pointer value, the result compares equal to the original pointervalue. If two pointers point to the same object or both point one past the end of the same array or bothare null, and the two pointers are subtracted, the result compares equal to the value 0 converted to the typestd::ptrdiff_t.82) Another way to approach pointer arithmetic is first to convert the pointer(s) to character pointer(s): In this scheme theintegral value of the expression added to or subtracted from the converted pointer is first multiplied by the size of the objectoriginally pointed to, and the resulting pointer is converted back to the original type.

For pointer subtraction, the result of thedifference between the character pointers is similarly divided by the size of the object originally pointed to.When viewed in this way, an implementation need only provide one extra byte (which might overlap another object in theprogram) just after the end of the object in order to satisfy the “one past the last element” requirements.§ 5.7120© ISO/IEC 2011 – All rights reservedISO/IEC 14882:2011(E)5.81Shift operators[expr.shift]The shift operators << and >> group left-to-right.shift-expression:additive-expressionshift-expression << additive-expressionshift-expression >> additive-expressionThe operands shall be of integral or unscoped enumeration type and integral promotions are performed.The type of the result is that of the promoted left operand.

The behavior is undefined if the right operandis negative, or greater than or equal to the length in bits of the promoted left operand.2The value of E1 << E2 is E1 left-shifted E2 bit positions; vacated bits are zero-filled. If E1 has an unsignedtype, the value of the result is E1 × 2E2 , reduced modulo one more than the maximum value representablein the result type.

Otherwise, if E1 has a signed type and non-negative value, and E1 × 2E2 is representablein the result type, then that is the resulting value; otherwise, the behavior is undefined.3The value of E1 >> E2 is E1 right-shifted E2 bit positions. If E1 has an unsigned type or if E1 has a signedtype and a non-negative value, the value of the result is the integral part of the quotient of E1/2E2 . If E1has a signed type and a negative value, the resulting value is implementation-defined.5.91Relational operators[expr.rel]The relational operators group left-to-right.

[ Example: a<b<c means (a<b)<c and not (a<b)&&(b<c).— end example ]relational-expression:shift-expressionrelational-expressionrelational-expressionrelational-expressionrelational-expression< shift-expression> shift-expression<= shift-expression>= shift-expressionThe operands shall have arithmetic, enumeration, or pointer type, or type std::nullptr_t. The operators< (less than), > (greater than), <= (less than or equal to), and >= (greater than or equal to) all yield falseor true. The type of the result is bool.2The usual arithmetic conversions are performed on operands of arithmetic or enumeration type.

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

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

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

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