std::shared_ptr::unique
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. |
bool unique()const; | ||
Verifica se *this è l'istanza
shared_ptr
solo gestire l'oggetto corrente, vale a dire se use_count()==1.Original:
Checks if *this is the only
shared_ptr
instance managing the current object, i.e. whether use_count()==1.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
(Nessuno)
Original:
(none)
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]Valore di ritorno
true se *this è l'istanza
shared_ptr
solo gestire l'oggetto corrente, false altrimenti.Original:
true if *this is the only
shared_ptr
instance managing the current object, false otherwise.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]Esempio
#include <memory> #include <iostream> int main(){std::shared_ptr<int> sp1 {std::make_shared<int>(5)};std::cout<<"sp1.unique() == "<<std::boolalpha<< sp1.unique()<<std::endl; std::shared_ptr<int> sp2 {sp1};std::cout<<"sp1.unique() == "<<std::boolalpha<< sp1.unique()<<std::endl;}
Output:
sp1.unique() == true sp1.unique() == false
[modifica]Vedi anche
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. (metodo pubblico) |