问题标签 [ambiguous-call]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
c++ - 为什么“使用 MyBase::myMethod”会解决“对成员 myMethod 的请求不明确”?(不是菱形图案!!!)
背景:我提供了一种基于两种不同技术的虚拟文件结构:FUSE和 MTP。由于两个框架都需要不同的接口,我创建了两个为这些接口提供服务的基类。FUSE 框架只知道IFuseFile
接口,而 MTP 框架只知道IMTPFile
接口。这些基类具有纯虚方法,由派生类实现。
问题:当直接实现它时,我得到一个"request for member IsWriteable is ambiguous"
编译器(参见示例源)。
解决方案:在寻找解决方案时,我只找到了菱形图案。但是我只有普通的纯虚方法,没有普通的类。对我来说,一个简单using BASE::method
的伎俩。
问题:由于我using BASE::method
之前使用了 only for hidden 方法,我无法解释为什么这段代码可以解决我的问题。你能解释一下吗?这只是 GCC 错误/功能吗?
这个例子:
c++ - static_cast 未按预期处理优先级
知道为什么这不能按预期工作吗?
我的 gcc 4.8.1 抱怨一个模棱两可的调用,但 static_cast 不应该在像这种情况下“修复”优先级规则,在这种情况下你有 2 种具有相同优先级的类型?
c++ - 为什么 main() 下面的表达式 `df(1);` 没有歧义?
d.f(1);
为什么下面的表达式在andmain()
之间没有歧义?Base::f(int)
Derived::f(int)
c++ - C++ 模板和模棱两可的函数调用
一些我无法控制的代码有许多接受不同类型的重载函数
IE
而且我有一个模板函数,它可以理想地采用这些类型中的任何一种并将其传递给正确的 setValue 函数。
但我得到这个错误
我可以做些什么来解决这个问题,而无需像 setValue 的作者那样复制和粘贴每种类型的代码?
c++ - C++ 继承错误:模棱两可的错误
在下一个代码中,在 _tmain(..) 中调用 D::f 时出现模棱两可的错误,因为 B::f 覆盖了 A::f,A::vtable 中指向 f 的指针指向 B::f。
1)为什么编译器会给出模棱两可的错误?有人可以澄清一下吗?
2)我试图通过将 B::f(int) 更改为 B::f(char) 来重载 A::f(int) 但错误并没有消失!这是为什么?
继承图:
编码:
c++ - How is a method taking const char* as argument a near match to a method taking const int&?
The following code throws compiler error when I compile it.
On compilation I get the error :
error: call of overloaded 'max(const int&, const int&)' is ambiguous
note: candidates are:
note: const T& max(const T&, const T&) [with T =int]
note: const char* max(const char*, const char*)
How does max(const char*, const char*) becomes a near match for max(const int&, const int &) when we have the template method that matches the call?
c++ - 推导函数调用时的歧义问题
我有以下代码,它有两个版本的函数 foo。我想是否为需要调用 AVar 类型的 foo 传递了一个变量,否则如果为要调用的 AConst 版本传递了一个 const 。
目前编译器给了我一个模棱两可的错误。不知道如何解决它。
更新:根据 Leonid 的回答稍作修改,以下是根据需要工作的解决方案:
c# - Razor Generator: ambiguous calls and resource file issues
I'm currently trying to get Razor Generator to work with my Web Application. I have followed this tutorial http://stacktoheap.com/blog/2013/01/19/precompiling-razor-views-in-asp-dot-net-mvc-3/
I've ran into a lot of errors with my project.
and also
where UIStrings is just a resource file containing strings
I also have turned on MVCBuildViews
and the these error don't exist until I install Razor Generator. It seems I'm lost as to why these errors are happening.
c# - 为什么这不会引发关于模棱两可的方法的某种错误?
我正在四处寻找关于泛型我能做什么和不能做什么。我有这种情况,就我而言,编译器应该抛出关于模棱两可的方法调用的错误,但它编译得很好。这是为什么?
java - 将一种方法标记为首选方法以自动解决模棱两可的调用?
假设我给自己定义了一种新型的字节流(类似于 OutputStream):
另外,我有一个可以将字符串写入字节流的辅助类,为了灵活性,我希望有两个版本的方法,以便它可以与常规的 OutputStream 或我的新 MyByteStream 一起使用:
现在,如果我有一个扩展 OutputStream并实现 MyByteStream 的类,如下所示:
我不能像这样调用我的 StringWriter 的 write 方法:
因为它会给我以下错误:
我可以通过将 DebugStream 显式转换为字节流之一来解决问题,如下所示:
但是由于这两种方法无论如何都做完全相同的事情,我宁愿不必到处都做演员。有没有办法解决这个问题?喜欢将其中一种方法定义为此类模棱两可的调用的首选方法吗?或者也许是一些泛型的诡计?
笔记:
我想保持编译时类型安全性,所以下面的“解决方案”已经出来了: