ambiguity

Why does C# allow ambiguous function calls through optional arguments?

帅比萌擦擦* 提交于 2019-12-09 02:32:54
问题 I came across this today, and I am surprised that I haven't noticed it before. Given a simple C# program similar to the following: public class Program { public static void Main(string[] args) { Method(); // Called the method with no arguments. Method("a string"); // Called the method with a string. Console.ReadLine(); } public static void Method() { Console.WriteLine("Called the method with no arguments."); } public static void Method(string aString = "a string") { Console.WriteLine("Called

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

家住魔仙堡 提交于 2019-12-08 23:01:46
问题 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

Does C# 4.0 and a combination of optional parameters and overloads give you a warning about ambiguity?

做~自己de王妃 提交于 2019-12-08 19:38:07
问题 I've started reading Jon Skeet's early access version of his book, which contains sections on C# 4.0, and one thing struck me. Unfortunately I don't have Visual Studio 2010 available so I thought I'd just ask here instead and see if anyone knew the answer. If I have the following code, a mixture of existing code, and new code: public void SomeMethod(Int32 x, Int32 y) { ... } public void SomeMethod(Int32 x, Int32 y, Int32 z = 0) { ... } Will the compiler complain either at the definition site

Java do while, while

女生的网名这么多〃 提交于 2019-12-08 17:43:53
问题 what behaviour can I expect when I run this code: do while(testA) { // do stuff } while(testB); Will it behave like: do { while(testA) { // do stuff } } while(testB); Or: if(testA) { do { // do stuff } while(testA && testB); } Or something totally unexpected? I ask this question because I think this is quite ambiguous, and for other people searching on this topic, not because I am lazy to test it out. 回答1: It is equivalent to your first block: do { while(testA) { // do stuff } } while(testB);

Ambiguous overload accessing argument-less template functions with variadic parameters

久未见 提交于 2019-12-08 01:06:49
问题 Yeah, the title can scare babies, but it's actually quite straightforward. I am trying to store a function pointer to a specialized template function, namely boost::make_shared (boost 1.41), as illustrated: boost::shared_ptr<int> (*pt2Function)() = boost::make_shared<int>; However, it won't compile (GCC 4.4.1) due to the fact that boost::make_shared has the following two specializations which the compiler can't tell apart in this context: template< class T > boost::shared_ptr< T > make_shared

Ambiguous Reference/Value Versions of Functions

北城以北 提交于 2019-12-07 07:31:08
问题 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

Resolve overload ambiguity with SFINAE

落爺英雄遲暮 提交于 2019-12-06 11:17:04
I've found similar cases, but they usually ended up doing something along the lines of what I (think) I'm doing here. I want to be able to call a function with one or more parameters, obviously, if the function exists with overloads with multiple parameters, the correct version cannot be deduced without help. As I am specifying the number of arguments as well, I figured this would be enough information for the compiler to deduce the correct overload. This doesn't seem to be the case and I hope you may be able to show me why. the code: http://coliru.stacked-crooked.com/a/5e6fd8d5418eee3c

Ambiguous overload accessing argument-less template functions with variadic parameters

依然范特西╮ 提交于 2019-12-06 06:40:20
Yeah, the title can scare babies, but it's actually quite straightforward. I am trying to store a function pointer to a specialized template function, namely boost::make_shared (boost 1.41), as illustrated: boost::shared_ptr<int> (*pt2Function)() = boost::make_shared<int>; However, it won't compile (GCC 4.4.1) due to the fact that boost::make_shared has the following two specializations which the compiler can't tell apart in this context: template< class T > boost::shared_ptr< T > make_shared() ... template< class T, class... Args > boost::shared_ptr< T > make_shared( Args && ... args ) The

Resolving ambiguity

不打扰是莪最后的温柔 提交于 2019-12-06 06:12:58
问题 I have a controller with 3 overloads for a create method: public ActionResult Create() {} public ActionResult Create(string Skill, int ProductId) {} public ActionResult Create(Skill Skill, Component Comp) {} in one of my views I want to create this thing so I call it like this: <div id="X"> @Html.Action("Create") </div> but I get the error: {"The current request for action 'Create' on controller type 'XController' is ambiguous between the following action methods: System.Web.Mvc.ActionResult

How to avoid ambiguity when calling Java from Matlab?

烈酒焚心 提交于 2019-12-06 04:37:44
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 Java call, instead of my using my method.m The fix is easy, just don't use the same method name for both