https://ja.wikipedia.org/wiki/%E5%AE%9F%E5%BC%95%E6%95%B0%E4%BE%9D%E5%AD%98%E3%81%AE%E5%90%8D%E5%89%8D%E6%8E%A2%E7%B4%A2
C++のADLは、意図しない挙動を引き起こすことがある。
基本的には必要な機能であるけれど、テンプレートと名前空間が絡んで意図しないLookupが起こるという話。
#include <iostream>
namespace test {
class bar { };
// ADL回避版
namespace foo {
template <typename T>
void f(T &) {
std::cout << "test::f" << std::endl;
}
}
using namespace foo;
// 意図しないADL
// template <typename T>
// void f(T &) {
// std::cout << "test::f" << std::endl;
// }
}
namespace x {
template <typename T>
void f(const T &) {
std::cout << "x::f" << std::endl;
}
template <typename T>
class hoge { };
}
int main() {
x::hoge<y::bar> h;
f(h);
}


