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
2 answers

Ambiguity between 'function1' and 'function2' (C++)

Let the source code speak for itself: MLine::MLine(int x1, int y1, int x2, int y2) { } MLine::MLine(double x1, double y1, double x2, double y2) { } void __fastcall TVctDiag2::PrepareArrowTail(int x, int y) { double length_x1; double…
truthseeker
  • 1,220
  • 4
  • 25
  • 58
0
votes
1 answer

ASP.NET MVC error: The call is ambiguous between the following methods or properties

I have a problem. In my View of a product I have a button to add it to cart which looks like this:
<% using(Html.BeginForm("AddToCart", "Cart")) {%> <%: Html.HiddenFor(x => x.id_produktu) %> <%: Html.Hidden("returnUrl",…
0
votes
1 answer

Ambigous extension method GetValueOrDefault when porting from .NET Framework to .NET

While porting my (large) application from .NET Framework 4.X to .NET 5+, stumbled over the new System.Collections.Generic.CollectionExtensions, which did not exist in the .NET Framework. Before it existed, I created an extension method…
LionAM
  • 1,271
  • 10
  • 28
0
votes
1 answer

overloading functions to use with both variables and literals - ambiguous call error

I'm trying to overload some functions to work with several data types. This is trivial when I'm passing variables as parameters, thusly: void fnc(int32_t d){ Serial.println((String) "int32 = " + d); } void fnc(char* d){ Serial.println((String)…
Robert M.
  • 575
  • 5
  • 17
0
votes
0 answers

How to restrict overloaded function applicability so that it only applies to certain types in order to avoid ambiguous call errors

I have a class that I use to apply functions to each element in a vector representing an image. template class func1_img_expr_t : public img_expr_t { public: std::function f; E e; …
0
votes
1 answer

Failed to understand (and fix) why this warning "call of overload xxx is ambiguous" exists

I'm stuck in fixing this gcc warning : I got tree version of the method "registerCalBack", each of them takes a different "callable" introduced through std::function. Depending on various callable type I declare, I can compile or not, gcc issuing a…
0
votes
4 answers

ambiguous call ? javascript functions and objects

I see that in jQuery to be specific var a= 'something' || function () { } or var a = 'something' || { } What does it mean? I know { } is an object json in javascript and am aware of anonymous functions in javascript but still cant figure out…
0
votes
1 answer

How to resolve ambiguity between constructors taking std::string and std::vector

I want to make a "Tag" class that can have its name specified either as a dot separated name like "this.is.my.name" or as a vector of strings, like {"this","is","my","name"}. When I try to do this, I am sometimes getting told by the compiler that…
stochastic
  • 3,155
  • 5
  • 27
  • 42
0
votes
2 answers

How to overload an in-place and a copying string manipulation functions?

I would like to be able to do the following: std::cout << str_manip("string to manipulate"); as well as std::string str; str_manip(str); std::cout << str; For this, I have two functions #include // copying std::string…
Sparkler
  • 2,581
  • 1
  • 22
  • 41
0
votes
1 answer

Ambiguous Reference in Swift

I reference two frameworks [PDFGenerator and PDFKit] that both contain an object named PDFPage. In the PDFGenerator framework, PDFPage is an Enum. In the PDFKit framework, PDFPage is an object. When I try to create an instance of the PDFPage Enum…
0
votes
1 answer

What is the correct syntax to supply a class to Mockito.any() so that the verify() call is unambiguous?

I'm using Mockito.spy(...) on a non-Mock object to verify that one of its methods is never called. However, there's an ambiguity because I'm just using any(), any(), and there are two overloads with two parameters: I'm a bit new to Java and can't…
Andrew Cheong
  • 29,362
  • 15
  • 90
  • 145
0
votes
1 answer

Resolving multiple inheritance ambiguity with enable_if

I have an event source base class, which defines a function to add listeners, and I'm trying to use a template argument to resolve ambiguity. But that doesn't seem to work - it always uses the function from the first base class and then complains…
riv
  • 6,846
  • 2
  • 34
  • 63
0
votes
0 answers

How do I debug this code (snippet) given an error message about ambiguous truth values in an array?

The first block of code shown below works; my issue is in trying to adapt that block of code to my problem (defined just below it). I am trying to use SCIPY to minimize the function chisq below. The entire code is basically a chain of functions…
user7345804
0
votes
1 answer

Ambiguous action methods with different HttpMethod

I'm experiencing a weird behaviour, at least to me. I written two methods within a controller with apparently different signatures: [Route("~/Wallets/{walletId}/Transactions/Add")] public async Task Add(long…
lucacelenza
  • 1,259
  • 1
  • 15
  • 28
0
votes
0 answers

Error:call of overloaded 'abs(float&)'

I am controlling a motor using the FRDM K64F, I am using a motor library from mbed. When compiling it is picking up this error in the header files that come with the library. In member function 'void…
user3473406
  • 115
  • 1
  • 10