std::unique_ptr::operator*
De cppreference.com
< cpp | memory | unique 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. |
typename std::add_lvalue_reference<T>::type operator*() const; |
(1) | (depuis C++11) |
pointer operator->() const; |
(2) | (depuis C++11) |
operator*
et operator->
fournir un accès à l'objet appartenant à *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.
Sommaire |
[modifier] Paramètres
(Aucun)
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.
[modifier] Retourne la valeur
1)Retourne l'objet appartient à *this, à savoir *get() .
2) 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.
Renvoie un pointeur sur l'objet possédé par *this, c'est à dire 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.
[modifier] Exceptions
1)peut jeter
2)
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.
[modifier] Exemple
#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); }
Résultat :
Foo::bar f(const Foo&)
[modifier] Voir aussi
renvoie un pointeur sur l'objet géré 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. (fonction membre publique) |