C++ factorial, primorial
Hans Aberg
haberg-1 at telia.com
Sun Jun 29 20:22:59 UTC 2014
On 29 Jun 2014, at 10:20, Marc Glisse <marc.glisse at inria.fr> wrote:
> Let us look at the possible ways a user could call the function (z is an mpz_class).
>
> 1) factorial(42)
> 2) factorial(z)
> 3) mpz_class::factorial(42)
> 4) mpz_class::factorial(z)
> 5) gmpxx::factorial(42)
> 6) gmpxx::factorial(z)
> 7) z.factorial()
It is good not mixing C name spaces and C++ namespace’s - there was some confusion in Bison with that at first. :-)
So, the “mpz” prefix is a C name space, not a part of the language, but a programming technique. What is the C++ counterpart? The “mp” part is the GMP C++ namespace whatever you now call it, while the “z” is the C++ class part.
So it would suffice to put it in the GMP C++ namespace, as the main function is to disambiguate against other same named functions (as in another library).
More information about the gmp-discuss
mailing list