ambiguous-call

“redundant cast to java.lang.Object” warning for necessary cast

一笑奈何 提交于 2020-12-28 06:51:45
问题 Consider this Minimal, Reproducible Example : interface Code { static void main(String[] args) { symbol( String.valueOf( true ? 'a' : true ? 'b' : true ? 'c' : fail() ) ); } private static void symbol(String symbol) { System.out.println(symbol); } private static <R> R fail() { throw null; } } (Being near minimal, true is a stand in for a useful boolean expression. We can ignore beyond the first ? : (in the real code, there are lots).) This 'obviously' gives the error. 4: reference to valueOf

“redundant cast to java.lang.Object” warning for necessary cast

爱⌒轻易说出口 提交于 2020-12-28 06:49:10
问题 Consider this Minimal, Reproducible Example : interface Code { static void main(String[] args) { symbol( String.valueOf( true ? 'a' : true ? 'b' : true ? 'c' : fail() ) ); } private static void symbol(String symbol) { System.out.println(symbol); } private static <R> R fail() { throw null; } } (Being near minimal, true is a stand in for a useful boolean expression. We can ignore beyond the first ? : (in the real code, there are lots).) This 'obviously' gives the error. 4: reference to valueOf

“redundant cast to java.lang.Object” warning for necessary cast

雨燕双飞 提交于 2020-12-28 06:47:48
问题 Consider this Minimal, Reproducible Example : interface Code { static void main(String[] args) { symbol( String.valueOf( true ? 'a' : true ? 'b' : true ? 'c' : fail() ) ); } private static void symbol(String symbol) { System.out.println(symbol); } private static <R> R fail() { throw null; } } (Being near minimal, true is a stand in for a useful boolean expression. We can ignore beyond the first ? : (in the real code, there are lots).) This 'obviously' gives the error. 4: reference to valueOf

Why does the most negative int value cause an error about ambiguous function overloads?

纵饮孤独 提交于 2019-12-28 01:55:10
问题 I'm learning about function overloading in C++ and came across this: void display(int a) { cout << "int" << endl; } void display(unsigned a) { cout << "unsigned" << endl; } int main() { int i = -2147483648; cout << i << endl; //will display -2147483648 display(-2147483648); } From what I understood, any value given in the int range (in my case int is 4 byte) will call display(int) and any value outside this range will be ambiguous (since the compiler cannot decide which function to call). It

Obviously ambiguous call does not cause a compilation error on GCC

北慕城南 提交于 2019-12-08 17:30:28
问题 I was surprised by the fact that GCC does not consider the call to foo() in the following program ambiguous: #include <iostream> struct B1 { bool foo(bool) { return true; } }; struct B2 { bool foo(bool) { return false; } }; struct C : public B1, public B2 { using B1::foo; using B2::foo; }; int main() { C c; // Compiles and prints `true` on GCC 4.7.2 and GCC 4.8.0 (beta); // does not compile on Clang 3.2 and ICC 13.0.1; std::cout << std::boolalpha << c.foo(true); } The above function call

How do I fix an “ambiguous” function call?

蓝咒 提交于 2019-12-05 13:24:21
问题 I'm working on a C++ program for class, and my compiler is complaining about an "ambiguous" function call. I suspect that this is because there are several functions defined with different parameters. How can I tell the compiler which one I want? Aside from a case-specific fix, is there a general rule, such as typecasting, which might solve these kinds of problems? Edit: In my case, I tried calling abs() inside of a cout statement, passing in two double s. cout << "Amount is:" << abs

Question about ambiguous calls in C#

只谈情不闲聊 提交于 2019-12-04 03:03:48
问题 I have a question that's not really a problem, but something that made me a little curious. I have a class with two methods in it. One is a static method and the other one is an instance method. The methods have the same name. public class BlockHeader { public static BlockHeader Peek(BinaryReader reader) { // Create a block header and peek at it. BlockHeader blockHeader = new BlockHeader(); blockHeader.Peek(reader); return blockHeader; } public virtual void Peek(BinaryReader reader) { // Do

Ambiguous occurrence in Haskell with “show”

巧了我就是萌 提交于 2019-12-02 11:29:48
问题 I'm new in functional programming and I'm trying to create and show a Stack with Haskell. I'd like my program to show me the Stack I'm building with it. This is my code: module Stack (Stack, empty, push, pop, top, isEmpty) where data Stack a = EmptyStack | Stk a (Stack a) push x s = Stk x s top (Stk x s) = x pop (Stk _ s) = s empty = EmptyStack isEmpty EmptyStack = True isEmpty (Stk x s) = False` instance Show a => Show (Stack a) where show EmptyStack = "|" show (Stk a b) = (show a) ++ " <- "