struct cls{
~cls(){std::cout<<"dtor\n";}
};
void foo(cls** pp){
*pp = new cls;
}
int main()
{
cls* raw_ptr = 0;
foo(&raw_ptr);
std::unique_ptr<cls> u_ptr{raw_ptr};
}
Is there any way to directly access the raw_pointer
in the unique_ptr
to pass to the function foo(cls** pp)
?
Or
cls* raw_ptr = 0;
foo(&raw_ptr);
std::unique_ptr<cls> u_ptr{raw_ptr};
Is it the only way?
Note: I cannot change the signature of the function foo
.
Aucun commentaire:
Enregistrer un commentaire