std::auto_ptr
De 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. |
Déclaré dans l'en-tête <memory>
|
||
template< class T > class auto_ptr; |
(1) | (obsolète) |
template<> class auto_ptr<void> |
(2) | (obsolète) |
auto_ptr
est un pointeur intelligent qui gère un objet obtenu par l'intermédiaire nouveau et supprime cet objet quand auto_ptr
lui-même est détruit. Il peut être utilisé pour fournir une sécurité pour les objets exception allouée dynamiquement, pour le passage de la propriété des objets alloués dynamiquement en fonction, et pour renvoyer les objets à affectation dynamique de fonctions .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.
Copie d'une copie
2) auto_ptr
le pointeur et transfère la propriété à la destination: construction exemplaire à la fois et l'affectation copie de auto_ptr
modifier leurs arguments de la main droite, et la "copie" n'est pas égal à l'original. En raison de ces sémantique de la copie inhabituelles, auto_ptr
ne peuvent pas être placés dans des conteneurs standards. std::unique_ptr est préféré pour ceci et d'autres usages .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.
Spécialisation pour void type est fourni, il déclare la
element_type
typedef, mais pas de fonctions membres .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.
[modifier] Types de membres
Type du membre | Définition |
element_type | T |
[modifier] Fonctions membres
crée un nouveau 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. (fonction membre publique) | |
détruit un auto_ptr et l'objet géré 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 |