Namespace
Varianti

std::shared_ptr

Da cppreference.com.
< cpp‎ | memory


 
 
Utilità libreria
Tipo di supporto (basic types, RTTI, type traits)
Gestione della memoria dinamica
La gestione degli errori
Programma di utilità
Funzioni variadic
Data e ora
Funzione oggetti
initializer_list(C++11)
bitset
hash(C++11)
Gli operatori relazionali
Original:
Relational operators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rel_ops::operator!=
rel_ops::operator>
rel_ops::operator<=
rel_ops::operator>=
Coppie e tuple
Original:
Pairs and tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
pair
tuple(C++11)
piecewise_construct_t(C++11)
piecewise_construct(C++11)
Swap, in avanti e spostare
Original:
Swap, forward and move
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
swap
forward(C++11)
move(C++11)
move_if_noexcept(C++11)
declval(C++11)
 
Gestione della memoria dinamica
Basso livello di gestione della memoria
Allocatori
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 inizializzata stoccaggio
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
Puntatori intelligenti
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(deprecato)
owner_less(C++11)
enable_shared_from_this(C++11)
bad_weak_ptr(C++11)
default_delete(C++11)
Garbage collection supporto
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)
Varie
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)
C Library
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
Membri funzioni
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=
Modificatori
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
Osservatori
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
Non membri funzioni
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
atomic_compare_exchange_weak
atomic_compare_exchange_strong
atomic_compare_exchange_weak_explicit
atomic_compare_exchange_strong_explicit
std::hash
 
Defined in header <memory>
template< class T > class shared_ptr;
(dal C++11)
std::shared_ptr è un puntatore intelligente che mantiene la proprietà condivisa di un oggetto tramite un puntatore. Diversi oggetti shared_ptr può possedere lo stesso oggetto; l'oggetto viene distrutto quando l'ultimo shared_ptr rimasto che punta ad esso viene distrutto o resettato. L'oggetto viene distrutto con delete-expression o un deleter personalizzato che viene fornito allo shared_ptr durante la costruzione.
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 può anche possedere nessun oggetto, nel qual caso si parla di vuoto.
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 soddisfa i requisiti della CopyConstructible e 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.

Indice

[modifica] Membri tipi

Membro tipo
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

[modifica] Membri funzioni

constructs new shared_ptr
(membro pubblico funzione) [edit]
distrugge l'oggetto di proprietà, se non di più shared_ptrs collegamento ad esso
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.

(membro pubblico funzione) [edit]
assegna il 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.

(membro pubblico funzione) [edit]
Modificatori
Original:
Modifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
sostituisce l'oggetto gestito
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.

(membro pubblico funzione) [edit]
scambia gli oggetti gestiti
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.

(membro pubblico funzione) [edit]
Osservatori
Original:
Observers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
restituisce un puntatore all'oggetto gestito
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.

(membro pubblico funzione) [edit]
dereferenzia puntatore all'oggetto gestito
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.

(membro pubblico funzione) [edit]
restituisce il numero di oggetti shared_ptr riferiscono allo stesso oggetto gestito
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.

(membro pubblico funzione) [edit]
Verifica se l'oggetto gestito è gestito solo dall'istanza shared_ptr corrente
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.

(membro pubblico funzione) [edit]
controlla se è associato oggetto gestito
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.

(membro pubblico funzione) [edit]
fornisce proprietario a base di ordinazione di puntatori condivisi
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.

(membro pubblico funzione) [edit]

[modifica] Non membri funzioni

crea un puntatore condiviso che gestisce un nuovo oggetto
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.

(funzione di modello) [edit]
crea un puntatore condiviso che gestisce un nuovo oggetto allocato con un allocatore
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.

(funzione di modello) [edit]
vale static_cast, dynamic_cast const_cast o al tipo di oggetto gestito
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.

(funzione di modello) [edit]
restituisce il deleter del tipo specificato, se di proprietà
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.

(funzione di modello) [edit]
confronta con un altro o con 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.

(funzione di modello) [edit]
emette il valore del puntatore gestito un flusso di output
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.

(funzione di modello) [edit]
specializzata l'algoritmo 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.

(funzione di modello) [edit]
specializzata operazioni atomiche
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.

(funzione di modello) [edit]

[modifica] Helper classi

sostegno hash per 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 modello di specializzazione) [edit]

[modifica] Note di attuazione

In una tipica implementazione, std::shared_ptr contiene solo due puntatori:
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 puntatore dell'oggetto di riferimento
    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 puntatore al blocco di controllo'
    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.
Se il blocco di controllo è un oggetto allocati dinamicamente, che contiene:
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 puntatore all'oggetto gestito o l'oggetto gestito in sé
    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.
  • il 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'allocatore
    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.
  • il numero di shared_ptrs che possiedono l'oggetto gestito
    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.
  • il numero di weak_ptrs che fanno riferimento all'oggetto gestito
    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.
Quando shared_ptr viene creato chiamando std::make_shared o std::allocate_shared, il blocco di controllo contiene l'oggetto gestito direttamente, come un membro dati. Quando shared_ptr viene creato chiamando un costruttore, un puntatore viene memorizzato.
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.
Il puntatore in possesso del shared_ptr è direttamente quello restituito dalla get(), mentre il puntatore / oggetto in possesso del blocco di controllo è quello che sarà cancellato quando il numero di proprietari condivisi raggiunge lo zero: queste indicazioni non sono necessariamente uguali.
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.
Il distruttore della shared_ptr decrementa il numero dei proprietari condivisi del blocco di controllo, e se questo arriva a zero, il blocco di controllo chiama il distruttore dell'oggetto gestito, ma il blocco di controllo non si rilasciare fino a quando il contatore raggiunge lo zero std::weak_ptr pure.
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.