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

Template parameter is ambiguous: could not deduce template argument

I'm doing some kind of wrapper that looks like this: #include template void Apply(void (T::*cb)(Value), T* obj, Value v) { (obj->*cb)(v); } class Foo { public: void MyFunc(const int& i) { …
11
votes
5 answers

Sqlite : ambiguous column name

I'm a newbie and i try to do that on my database SELECT id FROM import a INNER JOIN import b ON a.id-1 =b.id AND b.val =0 WHERE a.val=-1 Pb : ambiguous column name: id My table : CREATE TABLE "import" ( "id" INTEGER PRIMARY KEY NOT NULL , …
user3459402
  • 111
  • 1
  • 1
  • 3
10
votes
2 answers

In Java, why is the call foo() not ambigious given 2 varags methods foo(int... ints) and foo(Object... objects)?

If I declare just the 2 varargs methods as follows: public void foo(String... strings) { System.out.println("Foo with Strings"); } and public void foo(int... ints) { System.out.println("Foo with ints"); } and then have the…
mikej
  • 65,295
  • 17
  • 152
  • 131
10
votes
2 answers

Creating a compatible String object

So I have an existing library that provides a string type. It implicitly converts to-from C style strings like so: struct TypeIDoNotOwn { TypeIDoNotOwn() {} TypeIDoNotOwn(TypeIDoNotOwn const&) {} TypeIDoNotOwn(char const*) {} TypeIDoNotOwn&…
Yakk - Adam Nevraumont
  • 262,606
  • 27
  • 330
  • 524
9
votes
1 answer

Why are these arguments ambiguous for a class constructor overload but not ambiguous for a function overload?

The issue is easily resolved by not being an implicit conversion fiend, but it seems like a strange inconsistency to me. Here's an example: #include void test1(int a, int b); // Overloaded function with two different void…
John Schock
  • 126
  • 4
9
votes
1 answer

The method is ambiguous for the type Error

I am trying to understand how Overloading in JAVA works and trying to get grasp of various overloading rules that are applied in case of widening, autoboxing and varargs in JAVA. I am not able to understand what is happening in the following…
theimpatientcoder
  • 1,184
  • 3
  • 19
  • 32
9
votes
2 answers

Getting ambiguous reference error in C# app due to cref reference in comments?

This is a new problem I've never seen before. It's occurring in an open source wrapper for LibCURL.NET: http://sourceforge.net/projects/libcurl-net/ I am getting an ambiguous reference "warning as error", but the odd part is that it's happening due…
Robert Oschler
  • 14,153
  • 18
  • 94
  • 227
9
votes
4 answers

Querying the inner join of two tables with the same column name, Column 'exName' in field list is ambiguous

I am querying the inner join of three tables using the following query. Two of the tables have columns named "name1". I am getting the following error. Column 'exName' in field list is ambiguous The "name1" columns are foreign key so the…
Ben Pearce
  • 6,884
  • 18
  • 70
  • 127
8
votes
9 answers

BC30560: 'default_aspx' is ambiguous in the namespace 'ASP'

When I compiled my latest asp.net program and trying to run on the test server, I am getting this error Line 46: Dim dependencies() As String Line 47: CType(Me,Global.System.Web.UI.Page).AppRelativeVirtualPath =…
Samuel
  • 1,949
  • 4
  • 18
  • 30
8
votes
2 answers

Why is this rvalue call ambiguous?

Why is this rvalue call ambiguous? I can have AA and AA& and the compiler will know to use AA&. But when i add in the third option i get an error. Obviously AA&& is a better overload then the others like int for an int is better then long. Why is…
user34537
8
votes
1 answer

Is invocable and ambiguous call: bug in either g++ or clang

Consider the following code: // Preamble #include #include // A base class template struct base {void operator()(T){};}; // Two derived classes inheriting from the same base classes template struct…
Vincent
  • 57,703
  • 61
  • 205
  • 388
8
votes
1 answer

Ambiguous C++ compiler error

The following bit of code fails to compile. The error seems to be some kind of ambigous call to the merge routine. My understanding is that STL has a merge routine found in the std namespace, but as far as I can tell the name merge in the code below…
Matthieu N.
8
votes
1 answer

No access or ambiguity check on templated member function found in multiple base classes

This compiles and runs fine on Visual C++ 2015 Update 3 RC: class A { template void f() {} }; class B : A {}; class C : A {}; class D : B, C {}; int main() { D d; d.f(); } There's two problems with this code: f() is…
isanae
  • 3,253
  • 1
  • 22
  • 47
8
votes
1 answer

C# The call is ambiguous between the following methods or properties: F(double)' and 'F(decimal)'

This code works quite well in C# despite the fact that int can be implicitly converted to double and float: void Main() { int x = 7; F(x); } void F(double a) { a.Dump("double"); } void F(float a) { a.Dump("float"); } So, why this…
8
votes
2 answers

What is an 'ambiguous type' error in Java?

In the following code, I get an error from the compiler on the last line that says: 'the type List is Ambiguous' (on the line that attempts to define cgxHist list). What am I doing wrong? import java.awt.*; import javax.swing.*; import…
user2671186
  • 107
  • 2
  • 2
  • 5
1 2
3
40 41