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

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

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

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

Otherwise,one of the following rules applies.— If E2 is a static data member and the type of E2 is T, then E1.E2 is an lvalue; the expression designatesthe named member of the class. The type of E1.E2 is T.— If E2 is a non-static data member and the type of E1 is “cq1 vq1 X”, and the type of E2 is “cq2 vq2T”, the expression designates the named member of the object designated by the first expression. IfE1 is an lvalue, then E1.E2 is an lvalue; if E1 is an xvalue, then E1.E2 is an xvalue; otherwise, it is aprvalue. Let the notation vq12 stand for the “union” of vq1 and vq2; that is, if vq1 or vq2 is volatile,then vq12 is volatile. Similarly, let the notation cq12 stand for the “union” of cq1 and cq2; that is,if cq1 or cq2 is const, then cq12 is const.

If E2 is declared to be a mutable member, then the typeof E1.E2 is “vq12 T”. If E2 is not declared to be a mutable member, then the type of E1.E2 is “cq12vq12 T”.— If E2 is a (possibly overloaded) member function, function overload resolution (13.3) is used to determine whether E1.E2 refers to a static or a non-static member function.— If it refers to a static member function and the type of E2 is “function of parameter-type-listreturning T”, then E1.E2 is an lvalue; the expression designates the static member function. Thetype of E1.E2 is the same type as that of E2, namely “function of parameter-type-list returningT”.— Otherwise, if E1.E2 refers to a non-static member function and the type of E2 is “function ofparameter-type-list cv ref-qualifieropt returning T”, then E1.E2 is a prvalue.

The expressiondesignates a non-static member function. The expression can be used only as the left-handoperand of a member function call (9.3). [ Note: Any redundant set of parentheses surroundingthe expression is ignored (5.1). — end note ] The type of E1.E2 is “function of parameter-type-listcv returning T”.— If E2 is a nested type, the expression E1.E2 is ill-formed.— If E2 is a member enumerator and the type of E2 is T, the expression E1.E2 is a prvalue. The type ofE1.E2 is T.5If E2 is a non-static data member or a non-static member function, the program is ill-formed if the class ofwhich E2 is directly a member is an ambiguous base (10.2) of the naming class (11.2) of E2.

[ Note: The64) If the class member access expression is evaluated, the subexpression evaluation happens even if the result is unnecessaryto determine the value of the entire postfix expression, for example if the id-expression denotes a static member.65) Note that (*(E1)) is an lvalue.§ 5.2.5© ISO/IEC 2011 – All rights reserved101ISO/IEC 14882:2011(E)program is also ill-formed if the naming class is an ambiguous base of the class type of the object expression;see 11.2. — end note ]5.2.6Increment and decrement[expr.post.incr]1The value of a postfix ++ expression is the value of its operand. [ Note: the value obtained is a copy ofthe original value — end note ] The operand shall be a modifiable lvalue. The type of the operand shall bean arithmetic type or a pointer to a complete object type.

The value of the operand object is modified byadding 1 to it, unless the object is of type bool, in which case it is set to true. [ Note: this use is deprecated,see Annex D. — end note ] The value computation of the ++ expression is sequenced before the modificationof the operand object. With respect to an indeterminately-sequenced function call, the operation of postfix++ is a single evaluation.

[ Note: Therefore, a function call shall not intervene between the lvalue-to-rvalueconversion and the side effect associated with any single postfix ++ operator. — end note ] The result is aprvalue. The type of the result is the cv-unqualified version of the type of the operand.

See also 5.7 and 5.17.2The operand of postfix -- is decremented analogously to the postfix ++ operator, except that the operandshall not be of type bool. [ Note: For prefix increment and decrement, see 5.3.2. — end note ]5.2.7Dynamic cast[expr.dynamic.cast]1The result of the expression dynamic_cast<T>(v) is the result of converting the expression v to type T. Tshall be a pointer or reference to a complete class type, or “pointer to cv void.” The dynamic_cast operatorshall not cast away constness (5.2.11).2If T is a pointer type, v shall be a prvalue of a pointer to complete class type, and the result is a prvalueof type T. If T is an lvalue reference type, v shall be an lvalue of a complete class type, and the result isan lvalue of the type referred to by T.

If T is an rvalue reference type, v shall be an expression having acomplete class type, and the result is an xvalue of the type referred to by T.3If the type of v is the same as T, or it is the same as T except that the class object type in T is morecv-qualified than the class object type in v, the result is v (converted if necessary).4If the value of v is a null pointer value in the pointer case, the result is the null pointer value of type T.5If T is “pointer to cv1 B” and v has type “pointer to cv2 D” such that B is a base class of D, the result is apointer to the unique B subobject of the D object pointed to by v. Similarly, if T is “reference to cv1 B” andv has type cv2 D such that B is a base class of D, the result is the unique B subobject of the D object referredto by v.

66 The result is an lvalue if T is an lvalue reference, or an xvalue if T is an rvalue reference. In boththe pointer and reference cases, the program is ill-formed if cv2 has greater cv-qualification than cv1 or if Bis an inaccessible or ambiguous base class of D. [ Example:struct B { };struct D : B { };void foo(D* dp) {B* bp = dynamic_cast<B*>(dp);}// equivalent to B* bp = dp;— end example ]6Otherwise, v shall be a pointer to or an lvalue of a polymorphic type (10.3).7If T is “pointer to cv void,” then the result is a pointer to the most derived object pointed to by v. Otherwise,a run-time check is applied to see if the object pointed or referred to by v can be converted to the typepointed or referred to by T.66) The most derived object (1.8) pointed or referred to by v can contain other B objects as base classes, but these are ignored.§ 5.2.7102© ISO/IEC 2011 – All rights reservedISO/IEC 14882:2011(E)8If C is the class type to which T points or refers, the run-time check logically executes as follows:— If, in the most derived object pointed (referred) to by v, v points (refers) to a public base classsubobject of a C object, and if only one object of type C is derived from the subobject pointed (referred)to by v the result points (refers) to that C object.— Otherwise, if v points (refers) to a public base class subobject of the most derived object, and thetype of the most derived object has a base class, of type C, that is unambiguous and public, the resultpoints (refers) to the C subobject of the most derived object.— Otherwise, the run-time check fails.9The value of a failed cast to pointer type is the null pointer value of the required result type.

A failed castto reference type throws std::bad_cast (18.7.2).[ Example:class A { virtual void f(); };class B { virtual void g(); };class D : public virtual A, privatevoid g() {Dd;B* bp = (B*)&d;A* ap = &d;D& dr = dynamic_cast<D&>(*bp);ap = dynamic_cast<A*>(bp);bp = dynamic_cast<B*>(ap);ap = dynamic_cast<A*>(&d);bp = dynamic_cast<B*>(&d);}class E : public D, public B { };class F : public E, public D { };void h() {Ff;A* ap = &f;D* dp = dynamic_cast<D*>(ap);E*E*ep = (E*)ap;ep1 = dynamic_cast<E*>(ap);B { };//////////////cast needed to break protectionpublic derivation, no cast neededfailsfailsfailssucceedsill-formed (not a run-time check)//////////succeeds: finds unique Afails: yields 0f has two D subobjectsill-formed: cast from virtual basesucceeds}— end example ] [ Note: 12.7 describes the behavior of a dynamic_cast applied to an object under construction or destruction. — end note ]5.2.8Type identification[expr.typeid]1The result of a typeid expression is an lvalue of static type const std::type_info (18.7.1) and dynamic typeconst std::type_info or const name where name is an implementation-defined class publicly derived fromstd :: type_info which preserves the behavior described in 18.7.1.67 The lifetime of the object referred to bythe lvalue extends to the end of the program.

Whether or not the destructor is called for the std::type_infoobject at the end of the program is unspecified.2When typeid is applied to a glvalue expression whose type is a polymorphic class type (10.3), the result refersto a std::type_info object representing the type of the most derived object (1.8) (that is, the dynamic67) The recommended name for such a class is extended_type_info.§ 5.2.8© ISO/IEC 2011 – All rights reserved103ISO/IEC 14882:2011(E)type) to which the glvalue refers.

If the glvalue expression is obtained by applying the unary * operator to apointer68 and the pointer is a null pointer value (4.10), the typeid expression throws the std::bad_typeidexception (18.7.3).3When typeid is applied to an expression other than a glvalue of a polymorphic class type, the result refersto a std::type_info object representing the static type of the expression. Lvalue-to-rvalue (4.1), array-topointer (4.2), and function-to-pointer (4.3) conversions are not applied to the expression.

If the type of theexpression is a class type, the class shall be completely-defined. The expression is an unevaluated operand(Clause 5).4When typeid is applied to a type-id, the result refers to a std::type_info object representing the type ofthe type-id. If the type of the type-id is a reference to a possibly cv-qualified type, the result of the typeidexpression refers to a std::type_info object representing the cv-unqualified referenced type. If the type ofthe type-id is a class type or a reference to a class type, the class shall be completely-defined.5The top-level cv-qualifiers of the glvalue expression or the type-id that is the operand of typeid are alwaysignored.

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

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

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

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