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
4
votes
5 answers

Ambiguous class name

If have a new project (ProjNew ) where I want to put several classes that are on other project (ProjOld). The problem is I want to maintain the old classes marked with Obsolete to avoid running all my projects and check if they using it. But in that…
Pedro Dias
  • 41
  • 2
4
votes
3 answers

Is there a way to specify a precedence among user defined conversions?

Disclaimer: I know that using user defined implicit conversions is often discouraged. However, in our project, we need these conversions for various template classes to work well with each other. I need to define a precedence of user defined…
gexicide
  • 38,535
  • 21
  • 92
  • 152
4
votes
1 answer

Why do I see NSAutoresizingMaskLayoutConstraint when all UI Elements are set to setTranslatesAutoresizingMaskIntoConstraints = NO

I am trying to debug a UI Layout and all the elements I have added in the code are labelled with [self.element setTranslatesAutoresizingMaskIntoConstraints:NO]; The only thing that is set in XIB file is the background color of the view (one of many…
Michael Rowe
  • 870
  • 2
  • 11
  • 27
4
votes
2 answers

C++ strange ambiguous call to overloaded function

First of all, this question is purely of theoretical nature. I am not searching for a solution (I already know it), I am just searching for an explanation. The following code doesn't compile: struct foo {}; void a(foo) {} namespace foobar { void…
florian
  • 63
  • 2
  • 4
4
votes
1 answer

Ambiguous non-terminal in GLR

When GLR parser reduces some text to the same non-terminal in two ore more ways it merges parse subtrees. Rekers uses 'symbol nodes' for this. I this not each non-terminal could cause a merge. Knowing in advance what non-terminals never merge will…
3
votes
3 answers

Why is one code faster than other even when iterations are more?

My code is short and has lesser number of iterations than the other but still it gets a time limit exceeded error while the other code is accepted on codechef.com. The codes are solution to the "Ambiguous permutation" problem on codechef.com Why is…
azuri
  • 61
  • 6
3
votes
3 answers

Ambiguous column in MySQL even with Alias

I have the following MySQL: select `car`.`ID` AS `ID`, `title`,`text` from `car` LEFT JOIN `truck` as bigcar ON bigcar.`ID` = `car`.`truckID` WHERE `ID` ='1'; For some reason I'm getting Column 'ID' in where clause is…
Asaf
  • 8,106
  • 19
  • 66
  • 116
3
votes
1 answer

C++ Overloaded function call is ambiguous

I was playing around with C++ std::function objects, and wanted to add some functionality to them, so I subclassed them. However, when I tried to create a function that overloaded based on the signature of the function that was passed to it, the…
3
votes
1 answer

Why isn't this class reference ambiguous?

I am wondering why this situation is not resulting in an ambiguous reference between types, one a class within our library and one an external struct. Consider the following- External struct- namespace External.Models { public struct ProxyUser …
tjack2006
  • 39
  • 3
3
votes
3 answers

Why do I get an error in this code when using "using namespace std;" and "bits/stdc++.h"?

Actually this code works fine in "DEV C++", but when I put it into my "Hacker-Rank" panel it gives this error "reference to function is ambiguous", although all the online compilers are giving errors... I don't think here function overloading is…
Pranshu_Taneja
  • 186
  • 1
  • 1
  • 16
3
votes
1 answer

Swift 4: Type of expression is ambiguous without more context inside loop

I have a question: I'm retrieving a long string made of some base 64 strings attached together with ";" separating each of them inside said string. Here's my code: if(item.photo != "null"){ let b64fullstring = item.photo …
3
votes
1 answer

Why in-scope implicit values typed A and B are not ambiguous when B extends A?

Why does the code in Test2 compile even though we clearly have ambiguous implicit values? object Method { def foo(implicit i: A): Unit = println(i.i) } trait A { val i: Int } class B(override val i: Int) extends A object Test1 { implicit…
samthebest
  • 30,803
  • 25
  • 102
  • 142
3
votes
1 answer

Same name in typedef and using from a namespace

Sample code: struct X { void f() {} }; typedef X A; namespace N { struct A { void g() {} }; }; using N::A; int main() { A a; a.f(); } This code compiles correctly, and A a; creates an X, not a N::A. What rule in the standard covers…
M.M
  • 138,810
  • 21
  • 208
  • 365
3
votes
1 answer

Implementing instance methods with ambiguous type variables not contained in the class head

Say I have two classes like this: {-# LANGUAGE MultiParamTypeClasses, AllowAmbiguousTypes, FlexibleContexts #-} class Foo a b class Bar a where foo :: Foo a b => a Notably, the b of foo can neither be inferred from the use of foo nor from the…
Kritzefitz
  • 2,644
  • 1
  • 20
  • 35
3
votes
1 answer

C++ override function from same base template class with multiple inheritance ambiguous function call

I need to call init(int* iNumber) function which is derived from the base class. BaseClass.h #pragma once #include "stdafx.h" template class BaseClass { public: BaseClass() {} virtual ~BaseClass() {} virtual void init(T*…