Questions tagged [ambiguous-call]

Ambiguous call is a situation, when compiler cannot deduce from the passed parameter types, which version of function or method shall it use.

Ambiguous call happens, when the parameters can be converted in many ways, such that they fit to more than one overload of a function. For example:

void f(float f)
{

}

void f(double d)
{

}

Passing an int value to this function will cause an ambiguous call compiler error, because int can be converted both to float and to double while the compiler is not able to choose the overloaded version of function uniquely.

102 questions
1
vote
1 answer

method overloading with QString or std::string : call is ambiguous

I have a class which looks like this : class MyClass { public: void drawText(const QString& rText); void drawText(const std::string& rText); }; I overloaded the drawText() method because I want to accept QString as well as std::string. But…
Jérôme
  • 26,567
  • 29
  • 98
  • 120
1
vote
1 answer

CS0121 Ambiguous overloaded function call with char, int, double parameters implicitly converted to user-defined types in C#

I've got some C# classes, MyChar, Myint, MyDouble, that wrap char, int and double. Each has an implicit conversion operator from the wrapped type to the user-defined one. I've also got a set of overloaded functions, ToString(MyChar),…
bonio
  • 21
  • 3
1
vote
1 answer

Error reference to 'distance' is ambiguous

I cannot figure out why I am getting the error "reference to 'distance' is ambiguous". I have passed class object as an argument in friend function. #include using namespace std; class distance { int meters = 0; public: …
1
vote
1 answer

C# Using dynamic lambda but getting an ambiguous match when selecting a method to use

I have the following static method for selecting between filter options as per a blog post by Pashov. public static class ExpressionRetriever { private static MethodInfo containsMethod = typeof(string).GetMethod("Contains"); …
si2030
  • 3,895
  • 8
  • 38
  • 87
1
vote
2 answers

ambiguous overloaded function differs only by argument's template parameter

Consider the following code: SmartPointer Fix(SmartPointer data) { return { /* Fixed Data */ }; } SmartPointer Fix(SmartPointer dataWrapper) { return Fix(dataWrapper->Data()); } How would I rewrite this so…
Patrick Parker
  • 4,863
  • 4
  • 19
  • 51
1
vote
1 answer

Ambiguity between generic and simple string in params

I have 2 methods, one of which works with generic param and other one with regular string. It looks like this : public static async Task PostAlertAsync(this IQueueService queueService, AlertTypes alertType, string orgId, …
Olha Shumeliuk
  • 720
  • 7
  • 14
1
vote
3 answers

How do I make std::sort not have name collision between std::swap and my namespace's templated swap?

I want to use std::sort, but the compile is failing with error C2668: std::swap: ambiguous call to overloaded function because there is a templated swap() function defined in my namespace that would be hard to get rid of. I don't care which swap it…
All The Rage
  • 743
  • 5
  • 24
1
vote
1 answer

E2251 Ambiguous overloaded call to

I inherited some Delphi components/code that currently compiles with C++ Builder 2007. I'm simply now trying to compile the components with C++ Builder RAD XE. I don't know Delphi (object pascal). Here are the versions of the 'Supports' functions…
Eric
  • 1,697
  • 5
  • 29
  • 39
1
vote
1 answer

How to solve ambiguity caused by function overloading like this?

I have a piece of code similar to this: #include using namespace std; template class Class { public: Class() {} void foo(T) {cout << "foo(T) is called \n";} void foo(T&) {cout << "foo(T&) is called \n";} }; int…
whoAmI
  • 358
  • 4
  • 16
1
vote
1 answer

Ambiguous occurrence in Haskell with "show"

I'm new in functional programming and I'm trying to create and show a Stack with Haskell. I'd like my program to show me the Stack I'm building with it. This is my code: module Stack (Stack, empty, push, pop, top, isEmpty) where data Stack a …
1
vote
2 answers

Why does this assignment operation results in ambiguous function call?

Consider following program it compiles and runs fine: #include #include using std::string; struct BB { // generic cast template operator T() const { std::cout<<"Generic cast\n"; return 0; } // string…
Destructor
  • 14,123
  • 11
  • 61
  • 126
1
vote
0 answers

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. The call…
Adam
  • 388
  • 1
  • 10
1
vote
1 answer

Ambiguous reference error in VS2010

We have a type called Action in our library. We support VS2005, 2008 and now trying to support VS2010 too. When I include the namespace containing our 'Action' type and also 'System' together in a file and try to use it, it cribs saying ambiguous…
Niranjan
  • 247
  • 1
  • 5
  • 10
1
vote
1 answer

Why does "using MyBase::myMethod" solve "request for member myMethod is ambiguous" ? (NOT diamond pattern!!!)

The Background: I offer a virtual file structure over two different technologies: FUSE and MTP. Since both frameworks need different interfaces, I ve created two base classes which serve these interfaces. The FUSE famework only knows the IFuseFile…
Charly
  • 1,270
  • 19
  • 42
1
vote
2 answers

JavaCC Ambiguities: How do I tell the parser to chose a certain match from the the list of "longer matches"?

For some input, the parser presents a "Possible kinds of longer matches : { , }", but for some odd reason it chooses the wrong one. This is the source: SKIP : { " " | "\r" | "\t" | "\n" } TOKEN : { < DOT : "." > | < LBRACE…
cocalars
  • 11
  • 2