Template partial ordering – why does partial deduction succeed here

As discussed in the comments, I believe there are several aspects of the function template partial ordering algorithm that are unclear or not specified at all in the standard, and this shows in your example. To make things even more interesting, MSVC (I tested 12 and 14) rejects the call as ambiguous. I don’t think … Read more

String literal matches bool overload instead of std::string

“Hello World” is a string literal of type “array of 12 const char” which can be converted to a “pointer to const char” which can in turn be converted to a bool. That’s precisely what is happening. The compiler prefers this to using std::string‘s conversion constructor. A conversion sequence involving a conversion constructor is known … Read more

Why does pointer decay take priority over a deduced template?

The fundamental reason for this (standard-conforming) ambiguity appears to lie within the cost of conversion: Overload resolution tries to minimize the operations performed to convert an argument to the corresponding parameter. An array is effectively the pointer to its first element though, decorated with some compile-time type information. An array-to-pointer conversion doesn’t cost more than … Read more

How does the method overload resolution system decide which method to call when a null value is passed?

For the exact rules, see the overload resolution spec. But briefly, it goes like this. First, make a list of all the accessible constructors. public EffectOptions ( params object [ ] options ) public EffectOptions ( IEnumerable<object> options ) public EffectOptions ( string name ) public EffectOptions ( object owner ) public EffectOptions ( int … Read more