What are some good explanations on what argument dependent lookup is? Many people also call it Koenig Lookup as well.
Preferably I\'d like to know:
Not everything about it is good, in my opinion. People, including compiler vendors, have been insulting it because of its sometimes unfortunate behavior.
ADL is responsible for a major overhaul of the for-range loop in C++11. To understand why ADL can sometimes have unintended effects, consider that not only the namespaces where the arguments are defined are considered, but also the arguments of template arguments of the arguments, of parameter types of function types / pointee types of pointer types of those arguments, and so on and forth.
An example using boost
std::vector> v;
auto x = begin(v);
This resulted in an ambiguity if the user uses the boost.range library, because both std::begin
is found (by ADL using std::vector
) and boost::begin
is found (by ADL using boost::shared_ptr
).