std::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. |
Definido no cabeçalho <memory>
|
||
template< class T > class shared_ptr; |
(desde C++11) | |
std::shared_ptr
é um ponteiro inteligente que mantém a posse compartilhada de um objeto através de um ponteiro. Vários objetos shared_ptr
podem possuir o mesmo objeto; o objeto é destruído quando o último remanescente shared_ptr
apontando para ele é destruído ou reiniciado. O objeto é destruído usando expressão-delete ou um destruidor personalizado fornecido ao shared_ptr
durante sua construção.
Um shared_ptr
também pode possuir nenhum objeto, caso em que ele é chamado de "vazio".
shared_ptr
cumpre os requisitos da CopyConstructible
e CopyAssignable
.You can help to correct and verify the translation. Click here for instructions.
[editar] Tipos de membro
Tipo de membro
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 |
[editar] Funções de membro
constructs new shared_ptr (função pública membro) | |
destrói o objeto de propriedade, se nenhuma ligação mais shared_ptr s a ele Original: destructs the owned object if no more shared_ptr s 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. (função pública membro) | |
atribui o 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. (função pública membro) | |
Original: Modifiers The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
substitui o objeto gerenciado 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. (função pública membro) | |
troca os objetos gerenciados 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. (função pública membro) | |
Original: Observers The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
retorna um ponteiro para o objeto gerenciado 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. (função pública membro) | |
dereferences ponteiro para o objeto gerenciado 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. (função pública membro) | |
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) | |
Verifica se o objeto gerenciado é gerido apenas pela instância shared_ptr atual 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. (função pública membro) | |
verifica se existe é associado objeto gerenciado 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. (função pública membro) | |
fornece-proprietário baseado ordenação dos ponteiros compartilhados 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. (função pública membro) |
[editar] Não-membros funções
cria um ponteiro comum que gere um novo objeto 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. (modelo de função) | |
cria um ponteiro comum que gere um novo objeto alocado utilizando um alocador 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. (modelo de função) | |
aplica static_cast, dynamic_cast ou const_cast para o tipo de objeto gerenciado Original: The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (modelo de função) | |
retorna o deleter do tipo especificado, se possuía 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. (modelo de função) | |
compara com outro ou com 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. (modelo de função) | |
gera o valor do ponteiro de gestão para um fluxo de saída 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. (modelo de função) | |
(C++11) |
o algoritmo especializado 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. (modelo de função) |
especializada operações atômicas 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. (modelo de função) |
[editar] Classes auxiliares
(C++11) |
apoio de hash para 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. (especialização modelo. classe) |
[editar] Notas de implementação
You can help to correct and verify the translation. Click here for instructions.
- um ponteiro para o objeto referenciadoOriginal:a pointer to the referenced objectThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - um ponteiro para' bloco de controleOriginal:a pointer to control blockThe 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.
- um ponteiro para o objeto gerenciado ou o objeto gerenciado em siOriginal:a pointer to the managed object or the managed object itselfThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - o deleterOriginal:the deleterThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - alocadorOriginal:the allocatorThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - o número de
shared_ptr
s que possuem o objeto gerenciadoOriginal:the number ofshared_ptr
s that own the managed objectThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - o número de
weak_ptr
s que se referem ao objeto gerenciadoOriginal:the number ofweak_ptr
s that refer to the managed objectThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
shared_ptr
é criado chamando std::make_shared ou std::allocate_shared, o bloco de controle mantém o objeto gerenciado diretamente, como um membro de dados. Quando shared_ptr
é criado chamando um construtor, um ponteiro é armazenado.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.You can help to correct and verify the translation. Click here for instructions.
shared_ptr
diretamente é retornado por get()
, enquanto o ponteiro / objeto realizada pelo bloco de controle é o que vai ser suprimido quando o número de proprietários compartilhados atinge zero: esses ponteiros não são necessariamente iguais.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.You can help to correct and verify the translation. Click here for instructions.
shared_ptr
o número de proprietários compartilhada do bloco de controle, e se isso chegar a zero, o bloco de controle chama o destruidor do objeto gerenciado, mas o bloco de controle não desalocar-se até o balcão std::weak_ptr chega a zero, bem.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.You can help to correct and verify the translation. Click here for instructions.