为什么这个电话是模棱两可的?

Why this call is ambiguous?

为了探索更多关于重载解析过程的信息,我阅读了这篇文章:http://accu.org/index.php/journals/268

特殊性"Ordering of User-Defined Conversion Sequences"部分有这个例子:

struct A;
struct B {
  B(A const&);
};

struct A {
  operator B() const;
  operator int() const;
};
void func(B);
void func(int);

func(A());

最初我认为调用是不明确的,因为在结构 A

中有以下转换运算符
  operator B() const; //-> A::operator B(const A&) 
  operator int() const; //->  A::operator int(const A&) 

然后他们是这样解释的:

The call is ambiguous, however, the parameter B has an ambiguous conversion sequence and if the function having this parameter was eliminated the call would not be ambiguous. This is because there would be only one function to select.

这完全超出了我的脑海,所以我想我应该站起来再读一遍,但我还是没看懂grins

如果有人能用简单的术语解释事件的顺序以及上面引用的文章段落的含义,我将不胜感激:)非常感谢:)

它试图说明文章上一段中提出的观点。

您永远无法成功地将 A 传递给 void func(B),因为您已识别出不明确的转换序列。但是为了解决重载问题,重载仍然被认为是可行的。

如果它从可行集中移除,那么对 func 的调用将明确调用 void func(int),因为没有其他选择。这可能不是正确的做法。