Function return values in GMP?

Hans Aberg haberg at math.su.se
Mon Feb 27 07:11:11 CET 2006


On 27 Feb 2006, at 01:12, Décio Luiz Gazzoni Filho wrote:

>> Even when using C++, it is unwise to return values, especially for  
>> dynamically allocated variables, due to the time it takes, unless  
>> one uses some kind a reference method (like a reference count).
>
> mpz_t is a pointer type, so that's a non-sequitur. It really comes  
> down to the points made in the previous email -- syntactic sugar  
> vs. flexibility of memory management.

I mean in the C++ appropriate wrapper, of course. Then you can not  
use pointers as a substitute for return values, as new memory  
allocations may be needed, and then will require cleanup. Try to  
make, for example, a class "integer", with an
   integer operator+(const& integer, const& integer);
so see what happens.

   Hans Aberg




More information about the gmp-discuss mailing list