ambiguous

Antlr (lexer): matching the right token

痞子三分冷 提交于 2019-12-11 00:22:55
问题 In my Antlr3 grammar, I have several "overlapping" lexer rules, like this: NAT: ('0' .. '9')+ ; INT: ('+' | '-')? ('0' .. '9')+ ; BITVECTOR: ('0' | '1')* ; Although tokens like 100110 and 123 can be matched by more than one of those rules, it is always determined by context which of them it has to be. Example: s: a | b | c ; a: '<' NAT '>' ; b: '{' INT '}' ; c: '[' BITVECTOR ']' ; The input {17} should then match { , INT , and } , but the lexer has already decided that 17 is a NAT-token. How

Is there a warning free template function to convert basic types to string

拈花ヽ惹草 提交于 2019-12-10 20:10:06
问题 I want to provide a templated function that converts most basic types to string. The best I have come up with so far is the following: template<typename T> inline std::string anyToString(const T& var) { std::ostringstream o; o << var; return o.str(); } The function can e.g. be used for the following: class TimeError:public std::runtime_error{ public: explicit TimeError(int time):std::runtime_error(anyToString(time)), mTime(time){}; protected: int mTime; }; The problem with anyToString and

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

不羁的心 提交于 2019-12-10 19:22:47
问题 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 val i1: A = new A { val i: Int = 20 } } object Test2 { implicit val i2: B = new B(10) import Test1._ // This compiles fine and prints 10 Method.foo } object Test3 { implicit val i2: A = new B(10) import Test1._ // This does not compile, get `ambiguous

Color(int, int, int) vs Color(float, float, float) ambiguous call

拜拜、爱过 提交于 2019-12-10 18:18:11
问题 How can I resolve the ambiguous call between these two in C++? Color(int, int, int) Color(float, float, float) It is both ambiguous when the values are hardcoded i.e. Color(1, 2, 3) and when they are variables Color(r, g, b) . Why wouldn't the compiler resolve according to data type? In variable form? EDIT: Sorry, too much C++ makes me forget there's a other languages. And there is not much "full code" that was all about it. float x, y, z; int r, g, b; Color(1, 2, 3); // ambiguous Color(1.0,

Overloading member function among multiple base classes

扶醉桌前 提交于 2019-12-10 18:02:07
问题 Basically I want to have multiple member functions with same name, but different signature, spread in multiple base classes. Example: #include <iostream> struct A { void print(int) { std::cout << "Got an int!" << std::endl; } }; struct B { void print(double) { std::cout << "Got a double!" << std::endl; } }; struct C : A, B {}; int main() { C c; c.print((int)0); return 0; }; But I got this error on clang: main.cpp:18:7: error: member 'print' found in multiple base classes of different types c

Ambiguous class inheritance

一世执手 提交于 2019-12-10 14:09:20
问题 #include <iostream> #include <cmath> using namespace std; class Tcirculo{ float radio; float diametro; float area; public: void carea(float r){radio= r; area=(M_PI*((r*r)));} float cdiam(float r) {diametro = 2*r; return diametro;} float getr(){return radio;} float getd(){return diametro;} float geta(){return area;} }; class Trectangulo : public Tcirculo{ float altura; public: float calca(float h, float r){altura =h; float arearec = getd() * h; return arearec;} }; class Tcilindro : public

How to deal with an overload resolution ambiguity of functions with generics?

≡放荡痞女 提交于 2019-12-10 12:45:19
问题 Consider this class with two functions, one with Int argument, the other with a generic one: class C<K, V> { // ... operator fun f(index: Int): Pair<K, V> = ... operator fun f(key: K): V = ... } When it is parameterized as C<Int, SomeType> , K is Int , and both functions match the calls, resulting into an error: val m = C<Int, SomeType>() m.f(1) Overload resolution ambiguity. All these functions match: public final fun f(index: Int): SomeType defined in C public final fun f(key: Int): Pair

Error when creating bean with type java.io.File [Ambiguous constructor argument types]

别来无恙 提交于 2019-12-10 12:31:30
问题 I have the following spring bean configuration <bean id="fileBean" class="java.io.File"> <constructor-arg type="java.lang.String" value="$prop{file.path.property}" /> </bean> I'm getting the following error org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fileBean' defined in class path resource [context.xml]: Unsatisfied dependency expressed through constructor argument with index 0 of type [java.net.URI]: Ambiguous constructor argument types -

Specflow test step inheritance causes “Ambiguous step definitions”

…衆ロ難τιáo~ 提交于 2019-12-10 01:23:48
问题 I want to have the following test step class structure: [Binding] public class BaseStep { [Given(@"there is a customer")] public void GivenThereIsACustomer(Table table) { HandleCustomer(table); } protected virtual void HandleCustomer(Table table) { } } [Binding] public class FeatureOneStep : BaseStep { protected override void HandleCustomer(Table table) { // feature one action } [Given(@"feature one specific step")] public void GivenFeatureOneSpecificAction(Table table) { // do something } }

Ambiguous C++ compiler error

ぃ、小莉子 提交于 2019-12-09 16:23:53
问题 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 should be unique. If I rename merge to xmerge, everything works. What could the problem be? where is the name clash coming from? http://codepad.org/uAKciGy5 #include <iostream> #include <iterator> #include <vector> template<typename InputIterator1