Function return values in GMP? (James Wheaton)

Décio Luiz Gazzoni Filho decio at
Thu Mar 2 00:33:02 CET 2006

On Mar 1, 2006, at 7:53 PM, Daniel J Farrell wrote:

> A = B + C
> means that a temp object containing the value of B+C need to be
> created inside you method/function, passed into the memory space for
> A, then destroyed.
> A =+ B
> is different because you can get away with using A as the temp
> because your just summing into it every time.
> It's stuff like this that isn't apparent until you actually sit down
> an write the code. Hence that's why the result gmp variable is passed
> as a function argument - to by pass the memory management issues of
> temp variables.

Actually that is a well known problem with operator overloading in C+ 
+ and which has been solved (though not 100% satisfactorily) using  
the technique of `expression templates', which by the way is  
implemented in the C++ wrapper for GMP.


More information about the gmp-discuss mailing list