Espaces de noms
Variantes
Affichages
Actions

std::shared_ptr

De cppreference.com.

 
 
 
La gestion dynamique de la mémoire
Faible niveau de gestion de la mémoire
Répartiteurs
Original:
Allocators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
allocator
allocator_traits (C++11)
allocator_arg_t (C++11)
allocator_arg (C++11)
uses_allocator (C++11)
scoped_allocator_adaptor (C++11)
Non initialisée stockage
Original:
Uninitialized storage
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
uninitialized_copy
uninitialized_copy_n (C++11)
uninitialized_fill
uninitialized_fill_n
raw_storage_iterator
get_temporary_buffer
return_temporary_buffer
Pointeurs intelligents
Original:
Smart pointers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
unique_ptr (C++11)
shared_ptr (C++11)
weak_ptr (C++11)
auto_ptr (obsolète)
owner_less (C++11)
enable_shared_from_this (C++11)
bad_weak_ptr (C++11)
default_delete (C++11)
Soutien garbage collection
Original:
Garbage collection support
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
declare_reachable (C++11)
undeclare_reachable (C++11)
declare_no_pointers (C++11)
undeclare_no_pointers (C++11)
pointer_safety (C++11)
get_pointer_safety (C++11)
Divers
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
pointer_traits (C++11)
addressof (C++11)
align (C++11)
Bibliothèque C
Original:
C Library
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
std::shared_ptr
Les fonctions membres
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
shared_ptr::shared_ptr
shared_ptr::~shared_ptr
shared_ptr::operator=
Modificateurs
Original:
Modifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
shared_ptr::reset
shared_ptr::swap
Des observateurs
Original:
Observers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
shared_ptr::get
shared_ptr::operator*
shared_ptr::operator->
shared_ptr::use_count
shared_ptr::unique
shared_ptr::operator bool
shared_ptr::owner_before
Tiers fonctions
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
std::swap
make_shared
allocate_shared
static_pointer_cast
dynamic_pointer_cast
const_pointer_cast
get_deleter
operator==
operator|=
operator<
operator<=
operator>
operator>=
operator<<
atomic_is_lock_free
atomic_load
atomic_load_explicit
atomic_store
atomic_store_explicit
atomic_exchange
atomic_exchange_explicit
std::hash
 
Défini dans l'entête <memory>
template< class T > class shared_ptr;
(depuis C++11)
std::shared_ptr est un pointeur intelligent qui conserve la propriété partagée d'un objet via un pointeur. Plusieurs objets shared_ptr peut posséder le même objet, l'objet est détruit lorsque le shared_ptr dernier restant en montrant qu'il soit détruit ou remis à zéro. L'objet est détruit à l'aide delete-expression ou deleter personnalisé qui est fourni à shared_ptr pendant la construction .
Original:
std::shared_ptr is a smart pointer that retains shared ownership of an object through a pointer. Several shared_ptr objects may own the same object; the object is destroyed when the last remaining shared_ptr pointing to it is destroyed or reset. The object is destroyed using delete-expression or a custom deleter that is supplied to shared_ptr during construction.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Un shared_ptr peut aussi posséder aucun objet, dans ce cas, il est appelé vide .
Original:
A shared_ptr may also own no objects, in which case it is called empty.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
shared_ptr répond aux exigences de CopyConstructible et CopyAssignable .
Original:
shared_ptr meets the requirements of CopyConstructible and CopyAssignable.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Sommaire

[modifier] Types de membres

Type de membre
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

[modifier] Les fonctions membres

constructs new shared_ptr
(fonction membre publique) [edit]
Détruit l'objet possédé si aucun lien shared_ptrs plus à elle
Original:
destructs the owned object if no more shared_ptrs link to it
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) [edit]
assigne la shared_ptr
Original:
assigns the shared_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) [edit]
Modificateurs
Original:
Modifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
remplace l'objet géré
Original:
replaces 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.

(fonction membre publique) [edit]
permute les objets gérés
Original:
swaps the managed objects
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) [edit]
Des observateurs
Original:
Observers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
renvoie un pointeur sur l'objet géré
Original:
returns 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.

(fonction membre publique) [edit]
déréférence le pointeur à l'objet géré
Original:
dereferences 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.

(fonction membre publique) [edit]
retourne le nombre d'objets shared_ptr se référant au même objet géré
Original:
returns the number of shared_ptr objects referring to the same managed object
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) [edit]
vérifie si l'objet géré est gérée uniquement par l'instance actuelle shared_ptr
Original:
checks whether the managed object is managed only by the current shared_ptr instance
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) [edit]
vérifie si il est associé objet géré
Original:
checks if there is associated managed object
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) [edit]
fournit propriétaire-fondé l'ordre des pointeurs partagés
Original:
provides owner-based ordering of shared pointers
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) [edit]

[modifier] Tiers fonctions

crée un pointeur partagé qui gère un nouvel objet
Original:
creates a shared pointer that manages a new object
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction générique) [edit]
crée un pointeur partagé qui gère un nouvel objet alloué à l'aide d'un allocateur
Original:
creates a shared pointer that manages a new object allocated using an allocator
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction générique) [edit]
static_cast s'applique, dynamic_cast ou const_cast le type de l'objet géré
Original:
applies static_cast, dynamic_cast or const_cast to the type 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.

(fonction générique) [edit]
retourne le deleter du type spécifié, s'il était possédé
Original:
returns the deleter of specified type, if owned
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction générique) [edit]
compare avec un autre ou avec shared_ptr nullptr
Original:
compares with another shared_ptr or with nullptr
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction générique) [edit]
délivre en sortie la valeur du pointeur est parvenu à un flux de sortie
Original:
outputs the value of the managed pointer to an output stream
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction générique) [edit]
l'algorithme spécialisé std::swap
Original:
specializes the std::swap algorithm
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction générique) [edit]
se spécialise opérations atomiques
Original:
specializes atomic operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction générique) [edit]

[modifier] Classes d'aide

soutien de hachage pour std::shared_ptr
Original:
hash support for std::shared_ptr
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(classe générique spécialisée) [edit]

[modifier] Notes de mise en œuvre

Dans une mise en oeuvre typique, std::shared_ptr détient seulement deux pointeurs:
Original:
In a typical implementation, std::shared_ptr holds only two pointers:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • un pointeur vers l'objet référencé
    Original:
    a pointer to the referenced object
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • un pointeur de bloc de contrôle'
    Original:
    a pointer to control block
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
Où le bloc de contrôle est un objet allouée dynamiquement qui contient:
Original:
Where the control block is a dynamically-allocated object that holds:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • un pointeur vers l'objet géré ou l'objet lui-même géré
    Original:
    a pointer to the managed object or the managed object itself
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • le deleter
    Original:
    the deleter
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • l'allocateur
    Original:
    the allocator
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • le nombre de shared_ptrs qui possèdent l'objet géré
    Original:
    the number of shared_ptrs that own 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.
  • le nombre de weak_ptrs qui font référence à l'objet géré
    Original:
    the number of weak_ptrs that refer 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.
Lorsque shared_ptr est créée en appelant std::make_shared ou std::allocate_shared, le bloc de contrôle contient l'objet géré directement, en tant que membre de données. Lorsque shared_ptr est créée en appelant un constructeur, un pointeur est stocké .
Original:
When shared_ptr is created by calling std::make_shared or std::allocate_shared, the control block holds the managed object directly, as a data member. When shared_ptr is created by calling a constructor, a pointer is stored.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Le pointeur détenu par le shared_ptr est directement celle retournée par get(), tandis que le pointeur / objet tenu par le bloc de contrôle est celui qui sera supprimé lorsque le nombre de propriétaires partagés atteint zéro: ces pointeurs ne sont pas nécessairement égaux .
Original:
The pointer held by the shared_ptr directly is the one returned by get(), while the pointer/object held by the control block is the one that will be deleted when the number of shared owners reaches zero: these pointers are not necessarily equal.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Le destructeur de décrémente shared_ptr le nombre de propriétaires communs du bloc de contrôle, et si cela arrive à zéro, le bloc de commande appelle le destructeur de l'objet géré, mais le bloc de contrôle ne se libérer tant que le compteur atteint zéro std::weak_ptr ainsi .
Original:
The destructor of shared_ptr decrements the number of shared owners of the control block, and if that reaches zero, the control block calls the destructor of the managed object, but the control block does not deallocate itself until the std::weak_ptr counter reaches zero as well.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.