Questions tagged [ambiguous]

An ambiguous call is a situation in which the compiler cannot deduce which version of a function or method to use from the given parameter types. This tag should not be confused with the [ambiguity] tag.

An ambiguous call occurs when the parameters can be converted in many ways such that they fit 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.

612 questions
5
votes
1 answer

Call of overloaded function is ambiguous although different namespace

I do understand why the following would be a problem if no namespaces were used. The call would be ambiguous indeed. I thought "using stD::swap;" would define which method to use. Why does it work for "int" but not a "class"? #include
Lycosa
  • 53
  • 2
5
votes
0 answers

Eclipse Neon does not compile; ambiguous methods

we want to upgrade from Eclipse Mars to Neon, but our projects do not compile. In Mars, the following code compiles: public class AmbiguousMWE { private > void foo(final C c, final Function b) {} private…
benez
  • 1,856
  • 22
  • 28
5
votes
1 answer

Ambiguous call not avoided by SFINAE

Compiling this code : #include template struct TestClass { template ::type = 0> void doAction() { std::cout << "TestClass::doAction<" << N << ">();\n"; } }; struct HostClass…
Johnmph
  • 3,391
  • 24
  • 32
5
votes
1 answer

Is This Actually Ambiguous?

So I am aware that braces in code can mean more than just an initializer_list: What Is a Curly-Brace Enclosed List If Not an intializer_list? But what should they default to? For example, say that I define an overloaded function: void foo(const…
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
5
votes
1 answer

How do I resolve this ambiguous template constructor call?

I have a matrix class template: #include #include #include #include #include #include enum ColumnFill { COLUMNS }; template
Franko Leon Tokalić
  • 1,457
  • 3
  • 22
  • 28
5
votes
1 answer

Is it possible to solve ambiguous by annotations in Java

I have two methods that in some cases have ambiguous call. For example: void bla(Integer a); void bla(String a); Basically when I call bla(null) I will get ambiguous call error. Is it possible to write or use some annotation that will solve this…
Avi Levin
  • 1,868
  • 23
  • 32
5
votes
2 answers

g++ and clang++ - delete pointer acquired by overloaded conversion operator ambiguity

I was trying to post this code as an answer to this question, by making this pointer wrapper (replacing raw pointer). The idea is to delegate const to its pointee, so that the filter function can't modify the values. #include #include…
LogicStuff
  • 19,397
  • 6
  • 54
  • 74
5
votes
2 answers

Visual Studio shows C++ ambiguity errors after adding if-statement

I'm having this weird code issue. In visual studio all of my 'cout's, 'cin's, and my 'system' have red squiggles and are marked as ambiguous code. The project still compiles fine and doesn't give me any errors or warnings but it's annoying and will…
mattersonline
  • 183
  • 1
  • 10
5
votes
1 answer

Ambiguous conversion to reference

Why is the conversion of CL instance to const int& ambiguous here? struct CL { operator const int&() { } operator int&() { } }; void fnc(const int&) { } int main() { CL cl; fnc(cl); } There are two ways: 1).…
Denis
  • 2,786
  • 1
  • 14
  • 29
5
votes
4 answers

vb.net compile error 'abc' is ambiguous in the namespace 'xyz'

I have a VB.Net solution that another developer created and I'm trying to compile it on our build machine (it compiles on their machine) but with one of the projects I get an error saying something along the lines of: Imyinterface is ambiguous in…
Gern Blanston
  • 42,482
  • 19
  • 50
  • 64
5
votes
1 answer

JsonCpp ambiguous overload only in Windows

I need to read a json file with jsoncpp library. I have this file: {"one":false,"two":[{"id":"first"},{"id":"second"}],"three":550} If i need to read only the first id of "two" element, i use: std::string contents; //Contain the file Json::Value…
Safej
  • 73
  • 10
5
votes
2 answers

ICollection / ICollection ambiguity problem

Just want to make simple extension for syntactic sygar : public static bool IsNotEmpty(this ICollection obj) { return ((obj != null) && (obj.Count > 0)); } public static bool IsNotEmpty(this ICollection obj) { return ((obj !=…
Mose
  • 1,781
  • 3
  • 16
  • 35
5
votes
2 answers

ISO C++ says that these are ambiguous,

I have to overload the shift operator " << " both for writing in console and to write on a binary file.. I am doing okay for the ostream overloading, while I am having some problem overloading the fstream, here it is: in my header: friend ostream…
arocketman
  • 1,134
  • 12
  • 21
5
votes
5 answers

Optional parameters together with an array of parameters

I have a logging interface which I extend with some helpful extension methods as to make it possible for me to pass in a format and a list of arguments to avoid having to use string format every time a call the method. (it also help me follow FXCops…
Moriya
  • 7,750
  • 3
  • 35
  • 53
5
votes
1 answer

Ambiguous Column Reference with an AS alias

I am unsure as to how to resolve an ambiguous column reference when using an alias. Imagine two tables, a and b that both have a name column. If I join these two tables and alias the result, I do not know how to reference the name column for both…
Jack
  • 2,153
  • 5
  • 28
  • 43