Hello. I'm working with gnump and have a function that must return mpz_t
. So I have to use raw pointers to return a value. I allocate space with new
for pointer and send it as a parameter in my function.
I think it is better to use smart pointers. But I didn't work with them before. I read the manual but still can't understand how to use shared_ptr
properly to return a variable from a function.
shared_ptr<mpz_t> func()
{
mpz_t z;
mpz_init_set_str(z, "23423423423", 10);
shared_ptr<mpz_t> p /* Shall I allocate space with "new" or smth else?.. */
return p;
}
I would be grateful for any example.