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

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

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

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

[ Note: For temporaries,see 12.2. — end note ] Transfer out of a loop, out of a block, or back past an initialized variable withautomatic storage duration involves the destruction of objects with automatic storage duration that are inscope at the point transferred from but not at the point transferred to. (See 6.7 for transfers into blocks).[ Note: However, the program can be terminated (by calling std::exit() or std::abort() (18.5), forexample) without destroying class objects with automatic storage duration. — end note ]6.6.11[stmt.break]The break statement shall occur only in an iteration-statement or a switch statement and causes terminationof the smallest enclosing iteration-statement or switch statement; control passes to the statement followingthe terminated statement, if any.6.6.21The break statementThe continue statement[stmt.cont]The continue statement shall occur only in an iteration-statement and causes control to pass to the loopcontinuation portion of the smallest enclosing iteration-statement, that is, to the end of the loop.

Moreprecisely, in each of the statementswhile (foo) {{// ...}contin: ;}do {{// ...}contin: ;} while (foo);for (;;) {{// ...}contin: ;}a continue not contained in an enclosed iteration statement is equivalent to goto contin.6.6.3The return statement[stmt.return]1A function returns to its caller by the return statement.2A return statement with neither an expression nor a braced-init-list can be used only in functions that donot return a value, that is, a function with the return type void, a constructor (12.1), or a destructor (12.4).§ 6.6.3136© ISO/IEC 2011 – All rights reservedISO/IEC 14882:2011(E)A return statement with an expression of non-void type can be used only in functions returning a value; thevalue of the expression is returned to the caller of the function.

The value of the expression is implicitlyconverted to the return type of the function in which it appears. A return statement can involve theconstruction and copy or move of a temporary object (12.2). [ Note: A copy or move operation associatedwith a return statement may be elided or considered as an rvalue for the purpose of overload resolution inselecting a constructor (12.8). — end note ] A return statement with a braced-init-list initializes the objector reference to be returned from the function by copy-list-initialization (8.5.4) from the specified initializerlist.

[ Example:std::pair<std::string,int> f(const char* p, int x) {return {p,x};}— end example ]Flowing off the end of a function is equivalent to a return with no value; this results in undefined behaviorin a value-returning function.3A return statement with an expression of type void can be used only in functions with a return type of cvvoid; the expression is evaluated just before the function returns to its caller.6.6.41[stmt.goto]The goto statement unconditionally transfers control to the statement labeled by the identifier.

The identifiershall be a label (6.1) located in the current function.6.71The goto statementDeclaration statement[stmt.dcl]A declaration statement introduces one or more new identifiers into a block; it has the formdeclaration-statement:block-declarationIf an identifier introduced by a declaration was previously declared in an outer block, the outer declarationis hidden for the remainder of the block, after which it resumes its force.2Variables with automatic storage duration (3.7.3) are initialized each time their declaration-statement isexecuted. Variables with automatic storage duration declared in the block are destroyed on exit from theblock (6.6).3It is possible to transfer into a block, but not in a way that bypasses declarations with initialization. Aprogram that jumps87 from a point where a variable with automatic storage duration is not in scope to apoint where it is in scope is ill-formed unless the variable has scalar type, class type with a trivial defaultconstructor and a trivial destructor, a cv-qualified version of one of these types, or an array of one of thepreceding types and is declared without an initializer (8.5).

[ Example:void f() {// ...goto lx;// ...ly:X a = 1;// ...lx:goto ly;// ill-formed: jump into scope of a// OK, jump implies destructor// call for a followed by construction87) The transfer from the condition of a switch statement to a case label is considered a jump in this respect.§ 6.7© ISO/IEC 2011 – All rights reserved137ISO/IEC 14882:2011(E)// again immediately following label ly}— end example ]4The zero-initialization (8.5) of all block-scope variables with static storage duration (3.7.1) or thread storageduration (3.7.2) is performed before any other initialization takes place.

Constant initialization (3.6.2) of ablock-scope entity with static storage duration, if applicable, is performed before its block is first entered.An implementation is permitted to perform early initialization of other block-scope variables with static orthread storage duration under the same conditions that an implementation is permitted to statically initializea variable with static or thread storage duration in namespace scope (3.6.2). Otherwise such a variable isinitialized the first time control passes through its declaration; such a variable is considered initialized uponthe completion of its initialization.

If the initialization exits by throwing an exception, the initializationis not complete, so it will be tried again the next time control enters the declaration. If control entersthe declaration concurrently while the variable is being initialized, the concurrent execution shall wait forcompletion of the initialization.88 If control re-enters the declaration recursively while the variable is beinginitialized, the behavior is undefined. [ Example:int foo(int i) {static int s = foo(2*i);return i+1;}// recursive call - undefined— end example ]5The destructor for a block-scope object with static or thread storage duration will be executed if and onlyif it was constructed.

[ Note: 3.6.3 describes the order in which block-scope objects with static and threadstorage duration are destroyed. — end note ]6.81Ambiguity resolution[stmt.ambig]There is an ambiguity in the grammar involving expression-statements and declarations: An expressionstatement with a function-style explicit type conversion (5.2.3) as its leftmost subexpression can be indistinguishable from a declaration where the first declarator starts with a (. In those cases the statement is adeclaration. [ Note: To disambiguate, the whole statement might have to be examined to determine if it isan expression-statement or a declaration.

This disambiguates many examples. [ Example: assuming T is asimple-type-specifier (7.1.6),T(a)->m = 7;T(a)++;T(a,5)<<c;// expression-statement// expression-statement// expression-statementT(*d)(int);T(e)[5];T(f) = { 1, 2 };T(*g)(double(3));////////declarationdeclarationdeclarationdeclarationIn the last example above, g, which is a pointer to T, is initialized to double(3). This is of course ill-formedfor semantic reasons, but that does not affect the syntactic analysis. — end example ]2The remaining cases are declarations. [ Example:class T {// ...88) The implementation must not introduce any deadlock around execution of the initializer.§ 6.8138© ISO/IEC 2011 – All rights reservedISO/IEC 14882:2011(E)public:T();T(int);T(int, int);};T(a);T(*b)();T(c)=7;T(d),e,f=3;extern int h;T(g)(h,2);////////declarationdeclarationdeclarationdeclaration// declaration— end example ] — end note ]3The disambiguation is purely syntactic; that is, the meaning of the names occurring in such a statement,beyond whether they are type-names or not, is not generally used in or changed by the disambiguation.

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

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

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

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