I was looking at the Wikipedia entry on argument-dependent lookup, and (on Jan 04, 2014) the following example was given:
#include<iostream>
int main()
{
std::cout << "Hello World, where did operator<<() come from?" << std::endl;
}
... with the following comment:
Note that std::endl is a function but it needs full qualification, since it is used as an argument to operator<< (std::endl is a function pointer, not a function call).
My thought is that the comment is incorrect (or simply unclear). I am considering changing the comment to say, instead
Note that std::endl needs full qualification, because ADL does not apply to the arguments of a function call; it only applies to the function name itself.
Am I correct that the Wikipedia comment is incorrect? Is my proposed change correct? (I.e., is my understanding of ADL correct in this example?)
There's nothing wrong about what Wikipedia says.
is equivalent to the following (assuming
operator<<
is implemented as a free function)which clearly requires namespace qualification for both
cout
andendl
because this is argument-dependent lookup (of the function), not "argument lookup".The arguments determine the function to be called, not the way around.