vendredi 10 mars 2017

name lookup rules in template function

#include <iostream>
using namespace std;

template<typename T>
void adl(T)
{
  cout << "T";
}

struct S
{
};

template<typename T>
void call_adl(T t)
{
  adl(S());
  adl(t);
}

void adl(S)
{
  cout << "S";
}

int main ()
{
  call_adl(S());
}

Question> Why the result is "TS"? What is the name lookup rule inside template function?

http://ift.tt/2nokHpw

Thank you

Aucun commentaire:

Enregistrer un commentaire