Argument Dependent Lookup (ADL) is also known as Koenig Lookup. When an unqualified call (without any namespaces) is made to a function with user defined types, it will lookup the function inside the type’s namespace also.
This is what enables cout
’s stream operator.
std::cout << "hello";
In the above code, there’s no operator<<
in the global namespace. However, due to ADL, we lookup in the std
namespace where we find std::operator<<()
defined and that is used.