std::unique_ptr::operator*
De cppreference.com
|
|
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. |
<metanoindex/>
<tbody> </tbody> typename std::add_lvalue_reference<T>::type operator*() const; |
(1) | (desde C++11) |
pointer operator->() const; |
(2) | (desde C++11) |
operator* e operator-> fornecer acesso ao objeto pertencente a *this.Original:
operator* and operator-> provide access to the object owned by *this.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.
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.
Valor de retorno
1)
Retorna o objeto de propriedade de
*this, ou seja, *get().Original:
Returns the object owned by
*this, i.e. *get().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.
2)
Retorna um ponteiro para o objeto de propriedade de
*this, ou seja get().Original:
Returns a pointer to the object owned by
*this, i.e. get().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.
Exceções
1)
pode jogar
Original:
may throw
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.
2)
Exemplo
#include <iostream>
#include <memory>
struct Foo {
void bar() { std::cout << "Foo::bar\n"; }
};
void f(const Foo& foo)
{
std::cout << "f(const Foo&)\n";
}
int main()
{
std::unique_ptr<Foo> ptr(new Foo);
ptr->bar();
f(*ptr);
}
Saída:
Foo::bar
f(const Foo&)
Veja também
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) | |