如何在c ++中使用占位符来表示不需要的参数

时间:2016-11-13 00:54:49

标签: c++ parameters arguments placeholder gmp

我在GMP任意精度算术库中使用此函数:

Function: void mpz_gcdext (mpz_t g, mpz_t s, mpz_t t, const mpz_t a, const mpz_t b)

Set g to the greatest common divisor of a and b, and in addition set s and t to coefficients satisfying a*s + b*t = g. The value in g is always positive, even if one or both of a and b are negative (or zero if both inputs are zero). The values in s and t are chosen such that normally, abs(s) < abs(b) / (2 g) and abs(t) < abs(a) / (2 g), and these relations define s and t uniquely. There are a few exceptional cases:

If abs(a) = abs(b), then s = 0, t = sgn(b).

Otherwise, s = sgn(a) if b = 0 or abs(b) = 2 g, and t = sgn(b) if a = 0 or abs(a) = 2 g.

In all cases, s = 0 if and only if g = abs(b), i.e., if b divides a or a = b = 0.

If t is NULL then that value is not computed. 

我不需要&#39; g&#39;或者&#39; t&#39;并且不想为传递给这个函数的唯一目的创建变量。我可以做些什么来将像占位符这样的东西传递给这个特定的函数,我怎样才能在c ++中做到这一点呢?

1 个答案:

答案 0 :(得分:-1)

您可能会重载该功能。

void mpz_gcdext (mpz_t s, const mpz_t a, const mpz_t b)
{
    mpz_t g, t;
    // initialize g and t as needed
    mpz_gcdext(g, s, t, a, b);
}

这有帮助吗?