Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does this code call different template function in vs2005?
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COThe correct behavior is to call `T` in both cases, as they become perfect matches. `const char*` would be preferred if it was a perfect match to either, but it's not. Anything else is non-conforming, and you'll have to consult your compiler's documentation or chalk it up as a bug. *I would recommend using a newer compiler.*
      singulars
    2. CO@GManNickG: I disagree: the array-to-pointer conversion and qualification conversion both yield an exact match, so the nontemplate should be preferred in both cases. The latest versions of Clang and g++ both say I am wrong, though, so perhaps I am missing something. (I do agree with your advice to use a newer compiler, though Visual C++ 2012 exhibits the same behavior in this case.)
      singulars
    3. CO@James et al, I've updated my answer based on more info in the standard (regarding selecting best viable function where ranks are equal) - the extra stuff has to do with whether one conversion sequence is a subset of another (the subset is then preferred). So there's no preference between array-to-pointer and qualification, but there IS between array-to-pointer/qualification and qualification (the latter is preferred). Crikey, this has been an education on the C++ standard for me :-)
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload