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

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

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

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

[ Note: A program-supplied allocation function can obtain the address of the currentlyinstalled new_handler using the std::get_new_handler function (18.6.2.4). — end note ] If an allocationfunction declared with a non-throwing exception-specification (15.4) fails to allocate storage, it shall returna null pointer. Any other allocation function that fails to allocate storage shall indicate failure only bythrowing an exception of a type that would match a handler (15.3) of type std::bad_alloc (18.6.2.1).4A global allocation function is only called as the result of a new expression (5.3.4), or called directly using thefunction call syntax (5.2.2), or called indirectly through calls to the functions in the C++ standard library.[ Note: In particular, a global allocation function is not called to allocate storage for objects with staticstorage duration (3.7.1), for objects or references with thread storage duration (3.7.2), for objects of typestd::type_info (5.2.8), or for the copy of an object thrown by a throw expression (15.1).

— end note ]3.7.4.21Deallocation functions[basic.stc.dynamic.deallocation]Deallocation functions shall be class member functions or global functions; a program is ill-formed if deallocation functions are declared in a namespace scope other than global scope or declared static in globalscope.35) The intent is to have operator new() implementable by calling std::malloc() or std::calloc(), so the rules are substantially the same.

C++ differs from C in requiring a zero request to return a non-null pointer.§ 3.7.4.2© ISO/IEC 2011 – All rights reserved67ISO/IEC 14882:2011(E)2Each deallocation function shall return void and its first parameter shall be void*. A deallocation functioncan have more than one parameter. If a class T has a member deallocation function named operator deletewith exactly one parameter, then that function is a usual (non-placement) deallocation function.

If class Tdoes not declare such an operator delete but does declare a member deallocation function named operatordelete with exactly two parameters, the second of which has type std::size_t (18.2), then this functionis a usual deallocation function. Similarly, if a class T has a member deallocation function named operatordelete[] with exactly one parameter, then that function is a usual (non-placement) deallocation function.If class T does not declare such an operator delete[] but does declare a member deallocation functionnamed operator delete[] with exactly two parameters, the second of which has type std::size_t, thenthis function is a usual deallocation function.

A deallocation function can be an instance of a functiontemplate. Neither the first parameter nor the return type shall depend on a template parameter. [ Note:That is, a deallocation function template shall have a first parameter of type void* and a return type ofvoid (as specified above). — end note ] A deallocation function template shall have two or more functionparameters. A template instance is never a usual deallocation function, regardless of its signature.3If a deallocation function terminates by throwing an exception, the behavior is undefined. The value of thefirst argument supplied to a deallocation function may be a null pointer value; if so, and if the deallocationfunction is one supplied in the standard library, the call has no effect. Otherwise, the behavior is undefinedif the value supplied to operator delete(void*) in the standard library is not one of the values returnedby a previous invocation of either operator new(std::size_t) or operator new(std::size_t, conststd::nothrow_t&) in the standard library, and the behavior is undefined if the value supplied to operatordelete[](void*) in the standard library is not one of the values returned by a previous invocation ofeither operator new[](std::size_t) or operator new[](std::size_t, const std::nothrow_t&) in thestandard library.4If the argument given to a deallocation function in the standard library is a pointer that is not the null pointervalue (4.10), the deallocation function shall deallocate the storage referenced by the pointer, rendering invalidall pointers referring to any part of the deallocated storage.

The effect of using an invalid pointer value(including passing it to a deallocation function) is undefined.363.7.4.31Safely-derived pointers[basic.stc.dynamic.safety]A traceable pointer object is— an object of an object pointer type (3.9.2), or— an object of an integral type that is at least as large as std::intptr_t, or— a sequence of elements in an array of character type, where the size and alignment of the sequencematch those of some object pointer type.2A pointer value is a safely-derived pointer to a dynamic object only if it has an object pointer type and itis one of the following:— the value returned by a call to the C++ standard library implementation of ::operator new(std::size_t);37— the result of taking the address of an object (or one of its subobjects) designated by an lvalue resultingfrom dereferencing a safely-derived pointer value;— the result of well-defined pointer arithmetic (5.7) using a safely-derived pointer value;36) On some implementations, it causes a system-generated runtime fault.37) This section does not impose restrictions on dereferencing pointers to memory not allocated by ::operator new.

Thismaintains the ability of many C++ implementations to use binary libraries and components written in other languages. Inparticular, this applies to C binaries, because dereferencing pointers to memory allocated by malloc is not restricted.§ 3.7.4.368© ISO/IEC 2011 – All rights reservedISO/IEC 14882:2011(E)— the result of a well-defined pointer conversion (4.10, 5.4) of a safely-derived pointer value;— the result of a reinterpret_cast of a safely-derived pointer value;— the result of a reinterpret_cast of an integer representation of a safely-derived pointer value;— the value of an object whose value was copied from a traceable pointer object, where at the time ofthe copy the source object contained a copy of a safely-derived pointer value.3An integer value is an integer representation of a safely-derived pointer only if its type is at least as large asstd::intptr_t and it is one of the following:— the result of a reinterpret_cast of a safely-derived pointer value;— the result of a valid conversion of an integer representation of a safely-derived pointer value;— the value of an object whose value was copied from a traceable pointer object, where at the time ofthe copy the source object contained an integer representation of a safely-derived pointer value;— the result of an additive or bitwise operation, one of whose operands is an integer representation of asafely-derived pointer value P, if that result converted by reinterpret_cast<void*> would compareequal to a safely-derived pointer computable from reinterpret_cast<void*>(P).4An implementation may have relaxed pointer safety, in which case the validity of a pointer value does notdepend on whether it is a safely-derived pointer value.

Alternatively, an implementation may have strictpointer safety, in which case a pointer value that is not a safely-derived pointer value is an invalid pointervalue unless the referenced complete object is of dynamic storage duration and has previously been declaredreachable (20.6.4). [ Note: the effect of using an invalid pointer value (including passing it to a deallocationfunction) is undefined, see 3.7.4.2. This is true even if the unsafely-derived pointer value might compare equalto some safely-derived pointer value.

— end note ] It is implementation defined whether an implementationhas relaxed or strict pointer safety.3.7.51[basic.stc.inherit]The storage duration of member subobjects, base class subobjects and array elements is that of their completeobject (1.8).3.81Duration of subobjectsObject lifetime[basic.life]The lifetime of an object is a runtime property of the object. An object is said to have non-trivial initializationif it is of a class or aggregate type and it or one of its members is initialized by a constructor other than a trivialdefault constructor. [ Note: initialization by a trivial copy/move constructor is non-trivial initialization.

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

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

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

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