Take a look at the following test code:
template<class T> struct Wrap {};
template<typename T> inline
void fun (T *&Int)
{}
template<typename T> inline
void fun (Wrap<T> *&Int)
{}
int main()
{
int i = 6;
fun((char*&)(i));
fun((Wrap<char>*&)(i));
}
When I run this code in linux g ++, it works as expected. When fun () is called with char * &, it calls select function 1 straight forward. However, I am interested in when we call fun () with Wrap <char> * & and it calls choice 2. Although choices 1 and 2 are both valid for the second call, the compiler manages to select a slightly better rival → choice 2 (because it exist).
Question : is it guaranteed that the same behavior will be preserved for any other compiler for C ++? If not, is there another alternative to make it deterministic?