std::auto_ptr
Материал из cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Заголовочный файл <memory>
|
||
| template< class T > class auto_ptr; |
(1) | (устарело) |
| template<> class auto_ptr<void> |
(2) | (устарело) |
auto_ptr является смарт-указатель, который управляет объектом получены с помощью новых и удаляет этот объект, когда auto_ptr сам будет уничтожен. Он может быть использован для обеспечения безопасности исключений для динамически размещаемых объектов, для передачи собственности на динамически выделенные объекты в функции и для возвращения динамически выделенные объекты из функций.Original:
auto_ptr is a smart pointer that manages an object obtained via new and deletes that object when auto_ptr itself is destroyed. It may be used to provide exception safety for dynamically-allocated objects, for passing ownership of dynamically-allocated objects into functions and for returning dynamically-allocated objects from functions.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Копирование
2) auto_ptr копирует указатель и передачи права собственности на назначение: строительство и копирования и назначение auto_ptr изменить свое право аргументы стороны, и "копия" не совпадает с оригиналом. Из-за этих необычных семантики копирования, auto_ptr не могут быть помещены в стандартные контейнеры. std::unique_ptr является предпочтительным для этой и других целей.Original:
Copying an
auto_ptr copies the pointer and transfers ownership to the destination: both copy construction and copy assignment of auto_ptr modify their right hand arguments, and the "copy" is not equal to the original. Because of these unusual copy semantics, auto_ptr may not be placed in standard containers. std::unique_ptr is preferred for this and other uses.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Специализация по типу void, то она заявляет ЬурейеЕ
element_type, но ни один из членов функций.Original:
Specialization for type void is provided, it declares the typedef
element_type, but no member functions.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[править] Член типов
| Член типа
Original: Member type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
| element_type | T |
[править] Член функций
| создает новый auto_ptr Original: creates a new auto_ptr The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public функция-член) | |
| разрушает auto_ptr и управляемого объекта Original: destroys an auto_ptr and the managed object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public функция-член) | |
| передает собственность от другой auto_ptr Original: transfers ownership from another auto_ptr The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public функция-член) | |
| преобразует управляемый указатель на указатель на другой тип Original: converts the managed pointer to a pointer to different type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public функция-член) | |
Original: Modifiers The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
| разрушает управляемого объекта Original: destroys the managed object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public функция-член) | |
| выпускает собственности на управляемый объект Original: releases ownership of the managed object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public функция-член) | |
Original: Observers The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
| получает указатель на управляемый объект Original: obtains a pointer to the managed object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public функция-член) | |
| доступ к управляемому объекту Original: accesses the managed object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public функция-член) | |