Espaços nominais
Variantes
Acções

std::shared_ptr

Da cppreference.com
< cpp‎ | memory


 
 
Biblioteca de utilitários
Digite apoio (basic types, RTTI, type traits)
Gerenciamento de memória dinâmica
De tratamento de erros
Utilidades do programa
Variadic funções
Data e hora
Objetos de função
initializer_list(C++11)
bitset
hash(C++11)
Os operadores relacionais
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>=
Pares e tuplas
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)
Troque, avançar e avançar
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)
 
Gerenciamento de memória dinâmica
Gerenciamento de memória de baixo nível
Alocadores
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)
Uninitialized armazenamento
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
Ponteiros inteligentes
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(obsoleta)
owner_less(C++11)
enable_shared_from_this(C++11)
bad_weak_ptr(C++11)
default_delete(C++11)
Apoio a coleta de lixo
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)
Diversos
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
Funções de membro
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=
Modificadores
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
Observadores
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
Não-membros funções
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;
(a partir do C++ 11)
std::shared_ptr é um ponteiro inteligente que mantém a propriedade compartilhada de um objeto através de um ponteiro. Vários objetos shared_ptr pode possuir o mesmo objeto, o objeto é destruído quando o último remanescente shared_ptr apontando para ele é destruído ou reiniciado. O objecto é destruído usando delete-expression ou um deleter personalizada que é fornecido ao shared_ptr durante a construção.
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.
A shared_ptr também pode possuir nenhum objeto, caso em que ele é chamado de vazio.
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 cumpre os requisitos da 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.

Índice

[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) [edit]
destrói o objeto de propriedade, se nenhuma ligação mais shared_ptrs a ele
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.

(função pública membro) [edit]
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) [edit]
Modificadores
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) [edit]
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) [edit]
Observadores
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) [edit]
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) [edit]
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) [edit]
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) [edit]
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) [edit]
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) [edit]

[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) [edit]
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) [edit]
aplica static_cast, dynamic_cast ou const_cast para o tipo de objeto gerenciado
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.

(modelo de função) [edit]
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) [edit]
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) [edit]
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) [edit]
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) [edit]
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) [edit]

[editar] Classes auxiliares

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) [edit]

[editar] Notas de implementação

Numa implementação típica, std::shared_ptr prende apenas dois ponteiros:
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.
  • um ponteiro para o objeto referenciado
    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.
  • um ponteiro para' bloco de controle
    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.
Quando o bloco de controle é um objeto dinamicamente alocados que detém:
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.
  • um ponteiro para o objeto gerenciado ou o objeto gerenciado em si
    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.
  • o 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.
  • alocador
    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.
  • o número de shared_ptrs que possuem o objeto gerenciado
    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.
  • o número de weak_ptrs que se referem ao objeto gerenciado
    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 é 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.
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.
O ponteiro realizada pela 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.
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.
O destruidor de decréscimos 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.
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.