ambiguity

Ambiguous Reference/Value Versions of Functions

♀尐吖头ヾ 提交于 2019-12-05 12:45:13
Consider the following function prototypes: void Remove(SomeContainer& Vec, const std::size_t Index); SomeContainer Remove(SomeContainer Vec, const std::size_t Index); The second is implemented in terms of the first. That is to say, they are functionally identical in every way except that one is pass-by-reference and the other is pass-by-value. However, GCC says these are ambiguous in cases like this, even though the first form is the only one that does not return a value: Remove(SomeContainer, 123); Is there any workaround to this, or do I have to come up with different names for each form?

Context-sensitivity vs Ambiguity

跟風遠走 提交于 2019-12-05 12:39:29
问题 I'm confused about how context-sensitivity and ambiguity influence each other. What i think is correct is: Ambiguity: An ambiguous grammar leads to the construction of more than one parse-tree using either left or right derivation. A language where all possible grammars are ambiguous is an ambiguous language. For instance C++ is an ambiguous language because x * y always can mean two different things as discussed in: Why can't C++ be parsed with a LR(1) parser?. Context-sensitivity: A context

Why does direct list initialization causes ambiguity for type reference cast if cast operators to the type and reference to the type are declared?

久未见 提交于 2019-12-05 01:20:38
The question rose in context of this answer . Consider an example: struct foo { int value; operator int&(){ return value; } operator int(){ return value; } }; int main () { int &a(foo{}); // #1 //int &b{foo{}}; // #2 -- ambiguity int &c = foo{}; // #3 //int &d = {foo{}}; // #4-- ambiguity int &d { a }; // #5 int &e = { a }; // #6 (void)a; (void)c; (void)d; (void)e; } I don't understand why does #2 and #4 cause ambiguity while #1 and #3 does not. So the question is - why does direct list initialization causes ambiguity for implicit cast to reference if cast operators to the type and reference

What is wrong with this grammar? (ANTLRWorks 1.4)

心已入冬 提交于 2019-12-04 16:20:27
I have the following code written in ANTLRWorks 1.4 grammar hmm; s : (put_a_in_b)|(put_out_a)|(drop_kick)|(drop_a)|(put_on_a); put_a_in_b : (PUT_SYN)(ID)(IN_SYN)(ID); put_out_a : (PUT2_SYN)(OUT_SYN)(ID) | (E1)(ID); drop_kick : ('drop')('kick')(ID); drop_a : (DROP_SYN)(ID); put_on_a : (E2)(ID); PUT_SYN : 'put' | 'place' | 'drop'; PUT2_SYN : 'put' | 'douse'; IN_SYN : 'in' | 'into' | 'inside' | 'within'; OUT_SYN : 'out'; E1 : 'extinguish'|'douse'; DROP_SYN : 'drop' | 'throw' | 'relinquish'; WS : ( ' ' | '\t' | '\r' | '\n' ) {$channel=HIDDEN;}; ID : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..

LINQ to SQL: How to handle ambiguous column names when joining tables?

喜欢而已 提交于 2019-12-04 09:48:37
I'm going to bootstrap this question with a previous one I asked: LINQ to SQL: Multiple joins ON multiple Columns. Is this possible? So I have a LINQ query: var query = from t1 in myTABLE1List // List<TABLE_1> join t2 in myTABLE1List on new { t1.ColumnA, t1.ColumnB } equals new { t2.ColumnA, t2.ColumnB } join t3 in myTABLE1List on new { t2.ColumnA, t2.ColumnB } equals new { t3.ColumnA, t3.ColumnB } select new {t1.ColumnA, t2.ColumnA, t3.ColumnA } // Duplicate Anon type 'ColumnA' How can I resolve this? With explicit naming of the properties of the anonymous type select new {t1A = t1.ColumnA,

Ambiguous XML schema

馋奶兔 提交于 2019-12-04 04:22:34
I'm trying to produce a pretty simple XML schema for an XML similar to the following: <messages> <item> <important_tag></important_tag> </item> <item> <important_tag></important_tag> <tag2></tag2> </item> <item> <tag2></tag2> <tag3></tag3> </item> </messages> The idea is that <important_tag> will have a specific definition AND it may or may not appear under <item> . It may also appear more than once. Additionally, there may be other tags before or after <important_tag> that I can not name in advance. I would like to give a specific definition for <important_tag> . For example, define

Problems with an ambiguous grammar and PEG.js (no examples found)

六眼飞鱼酱① 提交于 2019-12-04 03:28:08
问题 I want to parse a file with lines of the following content: simple word abbr -8. (012) word, simple phrase, one another phrase - (simply dummy text of the printing; Lorem Ipsum : "Lorem" - has been the industry's standard dummy text, ever since the 1500s!; "It is a long established!"; "Sometimes by accident, sometimes on purpose (injected humour and the like)"; "sometimes on purpose") This is the end of the line so now explaining the parts (not all spaces are described, because of the markup

Context-sensitivity vs Ambiguity

核能气质少年 提交于 2019-12-03 23:48:41
I'm confused about how context-sensitivity and ambiguity influence each other. What i think is correct is: Ambiguity: An ambiguous grammar leads to the construction of more than one parse-tree using either left or right derivation. A language where all possible grammars are ambiguous is an ambiguous language. For instance C++ is an ambiguous language because x * y always can mean two different things as discussed in: Why can't C++ be parsed with a LR(1) parser? . Context-sensitivity: A context-sensitive grammar has rules where the left hand side of these rules may contain (non)terminal symbols

C# The call is ambiguous between the following methods or properties: 'System.Math.Round(double, int)' and 'System.Math.Round(decimal, int)

二次信任 提交于 2019-12-03 11:31:47
问题 My code won't compile due to the error below: The call is ambiguous between the following methods or properties: 'System.Math.Round(double, int)' and 'System.Math.Round(decimal, int) My code is Math.Round(new FileInfo(strFilePath).Length / 1024, 1) How can I fix this? Thanks 回答1: The problem is that you make an integer division (results also in an int ) and a int can be implicitly converted to both double and decimal . Therefore, you need to make sure the expression results in one of those;

Ambiguity with Action and Func parameter

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 10:08:26
How is it possible that this code TaskManager.RunSynchronously<MyObject>(fileMananager.BackupItems, package); causes a compile error The call is ambiguous between the following methods or properties: 'TaskManager.RunSynchronously<MyObject>(System.Action<MyObject>, MyObject)' and 'TaskManager.RunSynchronously<MyObject>(System.Func<MyObject, bool>, MyObject)' when signature of the action is public void BackupItems(MyObject package) and "ambiguous" methods are static class TaskManager { public static void RunSynchronously<TInput>(Action<TInput> task, TInput param) { Task.Factory.StartNew(() =>