std::allocate_shared
Da cppreference.com.
< cpp | memory | shared ptr
![]() |
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.
La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
Elemento definito nell'header <memory>
|
||
template< class T, class Alloc, class... Args > shared_ptr<T> allocate_shared( const Alloc& alloc, Args... args ); |
||
Costruisce un oggetto di tipo
T
e lo avvolge in un std::shared_ptr utilizzando args
della lista dei parametri per il costruttore di T
.Original:
Constructs an object of type
T
and wraps it in a std::shared_ptr using args
as the parameter list for the constructor of T
.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.
L'assegnazione di memoria è fatto utilizzando una copia di alloc, che soddisfi i requisiti
Allocator
.Original:
All memory allocation is done using a copy of alloc, which satisfies the
Allocator
requirements.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.
Indice |
[modifica] Parametri
alloc | - | The Allocator to use.
|
args... | - | elenco di argomenti con cui un'istanza di
T saranno costruiti .Original: list of arguments with which an instance of T will be constructed.The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[modifica] Valore di ritorno
std::shared_ptr di un'istanza di
T
tipo.Original:
std::shared_ptr of an instance of type
T
.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.
[modifica] Eccezioni
Può generare le eccezioni generate dal Alloc::allocate() o dal costruttore di
T
.Original:
Can throw the exceptions thrown from Alloc::allocate() or from the constructor of
T
.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.
[modifica] Note
Questa funzione alloca la memoria per l'oggetto T e per il blocco di controllo del shared_ptr con una dotazione di memoria singolo. Al contrario, la dichiarazione
std::shared_ptr<T> p(new T(Args...))
esegue due allocazioni di memoria, che possono sostenere un inutile sovraccarico.Original:
This function allocates memory for the T object and for the shared_ptr's control block with a single memory allocation. In contrast, the declaration
std::shared_ptr<T> p(new T(Args...))
performs two memory allocations, which may incur unnecessary overhead.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.
Una copia di
alloc
viene memorizzata come parte del blocco di controllo in modo che possa essere utilizzato per rilasciare una volta il numero di riferimenti sia condivisa e debole arrivare a zero.Original:
A copy of
alloc
is stored as part of the control block so that it can be used to deallocate it once both shared and weak reference counts reach zero.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.
[modifica] Vedi anche
constructs new shared_ptr (metodo pubblico) | |
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) |