std::unique_ptr::operator*
De cppreference.com
<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&)
