ambiguity

Overload: why List<String> and List<Integer> make ambiguous declaration? [duplicate]

点点圈 提交于 2021-01-28 05:06:56
问题 This question already has answers here : Method has the same erasure as another method in type (7 answers) Closed 3 years ago . Why doesn't this compile? I want to know the underlying reason. If List<String> is not the same type as List<Integer> why public String convert(List<String> strings) { return null; } and public String convert(List<Integer> strings) { return null; } make an ambiguous declaration? public class Converter { public void why() { List<String> strings = null; List<Integer>

Overload Resolution/Ambiguity in name lookup(which one)

谁都会走 提交于 2020-02-15 07:56:08
问题 $7.3.3/14 (C++03) struct A { int x(); }; struct B : A { }; struct C : A { using A::x; int x(int); }; struct D : B, C { using C::x; int x(double); }; int f(D* d) { return d->x(); // ambiguous: B::x or C::x } The comment in the code in 'f' indicates that one can expect ambiguity between 'B::x' or 'C::x'. However, on compiling with g++(ideone) or Comeau the errors are slightly different. These errors instead of indicating ambiguity in B::x or C::x indicate the fact that A is an ambiguous base of

Overload Resolution/Ambiguity in name lookup(which one)

倖福魔咒の 提交于 2020-02-15 07:55:55
问题 $7.3.3/14 (C++03) struct A { int x(); }; struct B : A { }; struct C : A { using A::x; int x(int); }; struct D : B, C { using C::x; int x(double); }; int f(D* d) { return d->x(); // ambiguous: B::x or C::x } The comment in the code in 'f' indicates that one can expect ambiguity between 'B::x' or 'C::x'. However, on compiling with g++(ideone) or Comeau the errors are slightly different. These errors instead of indicating ambiguity in B::x or C::x indicate the fact that A is an ambiguous base of

boost::shared_ptr and Return Type Resolver idiom

冷暖自知 提交于 2020-01-24 17:07:27
问题 I am currently working on a concept of Object known in Java or C# for C++. It would be similar to variant type like boost::any, however having wider functionality. For that purpose I am using boost::shared_ptr to internaly store actual data and I wanted to provide Return Type Resolver idiom for easily obtaining this data, as it is stored in actual implementation. I know I could use boost::shared_ptr automatic conversion during assigment operator or constructor but as I said shared_ptr is not

Why does IList<>.Reverse() not work like List<>().Reverse

无人久伴 提交于 2020-01-21 10:42:05
问题 I have problem with List<T>.Reverse() and Reverse(this IEnumerable<TSource> source) . Look to the code: // Part 1 List<int> list = new List<int> { 1, 2, 3 }; foreach (int x in list) Console.Write(x); Console.WriteLine(); list.Reverse(); foreach (int x in list) Console.Write(x); Console.WriteLine(); list.Reverse(); // Part2 IList<int> ilist = list; foreach (int x in list) Console.Write(x); Console.WriteLine(); ilist.Reverse(); foreach (int x in ilist) Console.Write(x); Console.WriteLine();

Why does Oracle SQL mysteriously resolve ambiguity in one joins and does not in others

99封情书 提交于 2020-01-13 14:56:32
问题 I'm an Oracle 10g user. I had to write some SQL queries, and spotted a mysterious (as I see it) behaviour. Let's pretend we have a table, which is able to join itself in some kind of simple two-level tree structure. The next query gives me "ambiguity error", which is expected: select title from table1 left join table1 on condition BUT if I would add one more table to the join, the ambiguity problem will simply go away: select title from table1 join table2 on other_condition left join table1

C++ Function Overloading Similar Conversions

守給你的承諾、 提交于 2020-01-04 02:54:33
问题 I'm getting an error which says that two overloads have similar conversions. I tried too many things but none helped. Here is that piece of code CString GetInput(int numberOfInput, BOOL clearBuffer = FALSE, UINT timeout = INPUT_TIMEOUT); CString GetInput(int numberOfInput, string szTerminationPattern, BOOL clearBuffer = FALSE, UINT timeout = INPUT_TIMEOUT); I can't understand how could string be equal to long ? I'm using Visual C++ 6 (yep I know its old, I'm working on legacy code, so I'm

How to avoid ambiguity when calling Java from Matlab?

淺唱寂寞╮ 提交于 2020-01-02 15:45:43
问题 I just discovered that when calling Java from Matlab object.method(arg1,...,argn) is equivalent to method(object, arg1,...,argn) The problem here is I also have a method.m that does some translation from Java to Matlab (eg. convert String[] to cell of strings). My method.m looks like function result = method(object, arg1,...argn) intermediate = object.method(arg1,...argn); result = translate(intermediate); What is happening is when I call method(object, arg1,...,argn) , it does the direct

Solving design involving multiple inheritance and composite classes in c++

我是研究僧i 提交于 2020-01-01 03:21:46
问题 I have struggled with this design problem for some time. I will do my best to explain what I am trying to do and the various approached that I have seen, what I am trying and why. I work in a scientific computing environment where I deal with the same kinds of objects repeatedly. Imagine a galaxy which contains solar systems, each solar system contains planetary systems and each planetary system contains moons. To this end I think of the situation as a “has a” situation, and thus I have used

Equivalent implicit operators: why are they legal?

老子叫甜甜 提交于 2019-12-30 06:39:11
问题 Update! See my dissection of a portion of the C# spec below; I think I must be missing something, because to me it looks like the behavior I'm describing in this question actually violates the spec. Update 2! OK, upon further reflection, and based on some comments, I think I now understand what's going on. The words "source type" in the spec refer to the type being converted from -- i.e., Type2 in my example below -- which simply means that the compiler is able to narrow the candidates down