ambiguity

How to handle a class name conflict when porting old code?

有些话、适合烂在心里 提交于 2019-11-30 05:40:38
问题 I'm trying to port an old library (that doesn't use namespaces as far as I can tell) to modern compilers. One of my targets can't tell the difference between System::TObject and ::TObject (without a namespace). System::TObject is native to the compiler. I've tried a using directive, i.e. using ::TObject; But that doesn't do it. The obvious solution is to wrap all the original library in a namespace and then calling it by name- that should avoid the ambiguity. But is that the wisest solution?

warning: refname 'xxx' is ambiguous when using git-svn

半城伤御伤魂 提交于 2019-11-30 02:39:26
I am using git as a frontend to Subversion (via git svn). So, for every svn trunk/branch I have remote branch in git named "remotes/xxx". For example "remotes/trunk", "remotes/coolfeature". Now I want have one "default" local branch for every remote branch, to use it for dcommit. The problem is that I want such branches to be named after Subversion branches, like "trunk", "coolfeature", so I have the following branches in git: trunk coolfeature remotes/trunk remotes/coolfeature The problem is that every time I reference "trunk" or "coolfeature" git complains branch name is ambiguous. Not a big

Anonymous Namespace Ambiguity

ⅰ亾dé卋堺 提交于 2019-11-29 09:12:08
Consider the following snippet: void Foo() // 1 { } namespace { void Foo() // 2 { } } int main() { Foo(); // Ambiguous. ::Foo(); // Calls the Foo in the global namespace (Foo #1). // I'm trying to call the `Foo` that's defined in the anonymous namespace (Foo #2). } How can I refer to something inside an anonymous namespace in this case? You can't. The standard contains the following section ( §7.3.1.1 , C++03): An unnamed-namespace-definition behaves as if it were replaced by namespace unique { /* empty body */ } using namespace unique; namespace unique { namespace-body } where all occurrences

Why Oracle 10g doesn't complain about column ambiguity?

只谈情不闲聊 提交于 2019-11-29 06:26:37
I'm using Oracle 10g (XE 10.2.0.1.0), and find a behavior that I don't understand: select * from employees manager join employees worker on MANAGER.EMPLOYEE_ID = WORKER.MANAGER_ID join departments on DEPARTMENTS.manager_id = 108 where department_id = 100 ; The problem is I think Oracle should have complain about the ambiguity of department_id in the where clause, since it's a column in both the table employees and departments . The fact is in Oracle 10g, it doesn't, and the result shows that it interprets the department_id as the one in departments . However, if I comment out the second join

template disambiguator

倾然丶 夕夏残阳落幕 提交于 2019-11-29 03:47:50
I'm trying to find any information about template keyword used as disambiguator, but there is nothing about that. Probably I'm searching wrong keywords, but there is nothing like .template or ->template in standard. Google shows only GCC problems from different forums, but not really explanation what is it used for. Code like that failed to compile without template keyword on line 11 (on GCC), but I'm not quite sure that this conforms standard. template<typename B> struct S1 { template<typename T> void test() {} }; template<typename T> struct S2 { S2() { S1<T>().template test<int>(); } }; int

C# interface method ambiguity

六眼飞鱼酱① 提交于 2019-11-29 01:02:24
Consider the following example: interface IBase1 { int Percentage { get; set; } } interface IBase2 { int Percentage { get; set; } } interface IAllYourBase : IBase1, IBase2 { } class AllYourBase : IAllYourBase { int percentage; int Percentage { get { return percentage; } set { percentage = value; } } } void Foo() { IAllYourBase iayb = new AllYourBase(); int percentage = iayb.Percentage; // Fails to compile. Ambiguity between 'Percentage' property. } In the example above, there is ambiguity between which Percentage property to call. Assuming the IBase1 and IBase2 interfaces may not be changed,

Ambiguous call expression in ANTLR4 grammar

被刻印的时光 ゝ 提交于 2019-11-28 14:32:00
I have a simple grammar (for demonstration) grammar Test; program : expression* EOF ; expression : Identifier | expression '(' expression? ')' | '(' expression ')' ; Identifier : [a-zA-Z_] [a-zA-Z_0-9?]* ; WS : [ \r\t\n]+ -> channel(HIDDEN) ; Obviously the second and third alternatives in the expression rule are ambiguous. I want to resolve this ambiguity by permitting the second alternative only if an expression is immediately followed by a '(' . So the following bar(foo) should match the second alternative while bar (foo) should match the 1st and 3rd alternatives (even if the token between

Why is it ambiguous to call overloaded ambig(long) and ambig(unsigned long) with an integer literal?

橙三吉。 提交于 2019-11-28 09:37:28
When compiling void ambig( signed long) { } void ambig(unsigned long) { } int main(void) { ambig(-1); return 0; } I get error C2668: 'ambig' : ambiguous call to overloaded function could be 'void ambig(unsigned long)' or 'void ambig(long)' while trying to match the argument list '(int)' I know I can 'fix' it by saying -1L instead of -1 , but why/how exactly is this considered ambiguous in the first place? You're passing an int to this overloaded function. Although human intuition says that ambig(signed long) ought to be preferred because your input is a negative integer (which cannot be

Compile time warning when using 'Microsoft.Office.Interop.Word._Document.Close'

隐身守侯 提交于 2019-11-28 00:41:44
Anyone know how to solve this warning message? Ambiguity between method 'Microsoft.Office.Interop.Word._Document.Close(ref object, ref object, ref object)' and non-method 'Microsoft.Office.Interop.Word.DocumentEvents2_Event.Close'. Using method group. Tod The only way I've managed to resolve the warning is to use an explicit cast: var doc_close = (Microsoft.Office.Interop.Word._Document) _doc; doc_close.Close(); If you already have a using for Microsoft.Office.Interop.Word you can simplify the cast to: var doc_close = (_Document) _doc; doc_close.Close(); or even just ((_Document)_doc).Close();

The variable 'MyException' is declared but never used

怎甘沉沦 提交于 2019-11-27 19:57:20
I need to clear this warning : try { doSomething() } catch (AmbiguousMatchException MyException) { doSomethingElse() } The complier is telling me : The variable 'MyException' is declared but never used How can I fix this. Jalal Said You can remove it like this: try { doSomething() } catch (AmbiguousMatchException) { doSomethingElse() } Use warning disable like this: try { doSomething() } #pragma warning disable 0168 catch (AmbiguousMatchException exception) #pragma warning restore 0168 { doSomethingElse() } Other familiar warning disable #pragma warning disable 0168 // variable declared but