std::unique_ptr::get_deleter
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> Deleter& get_deleter(); |
(desde C++11) | |
const Deleter& get_deleter() const; |
(desde C++11) | |
Devolve o objecto deleter que seria usado para a destruição do objecto gerido.
Original:
Returns the deleter object which would be used for destruction 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.
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
O objeto armazenado deleter.
Original:
The stored deleter object.
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
Exemplo
#include <iostream>
#include <memory>
struct Foo {
Foo() { std::cout << "Foo...\n"; }
~Foo() { std::cout << "~Foo...\n"; }
};
struct D {
void bar() { std::cout << "Call deleter D::bar()...\n"; }
void operator()(Foo* p) const {
std::cout << "Call delete for Foo object...\n";
delete p;
}
};
int main()
{
std::unique_ptr<Foo, D> up(new Foo(), D());
D& del = up.get_deleter();
del.bar();
}
Saída:
Foo...
Call deleter D::bar()...
Call delete for Foo object...
~Foo...