std::shared_ptr::unique
Da cppreference.com
< cpp | memory | shared ptr
![]() |
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. |
bool unique() const; |
||
Verifica se *this é a instância
shared_ptr
só gerir o objeto atual, ou seja, 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.
Índice |
[editar] Parâmetros
(Nenhum)
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.
[editar] Valor de retorno
true se *this é a instância
shared_ptr
só gerir o objeto atual, false contrário.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.
[editar] Exemplo
#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; }
Saída:
sp1.unique() == true sp1.unique() == false
[editar] Veja também
retorna o número de objetos shared_ptr referentes ao mesmo objeto gerenciado 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. (função pública membro) |