我无法理解依赖于参数(Koenig)查找的规则.
请考虑以下代码:
#include <iostream>
using namespace std;
namespace adl
{
struct Test { };
void foo1(Test const &) { cout << "ADL used (foo1)" << endl; }
void foo2(Test const &) { cout << "ADL used (foo2)" << endl; }
void foo3(Test const &) { cout << "ADL used (foo3)" << endl; }
}
struct foo1
{
foo1() { }
template<class T>
foo1(T const &) { cout << "ADL not used (foo1)" << endl; }
template<class T>
void operator()(T const …Run Code Online (Sandbox Code Playgroud)