In the Depend Lookup (or Koenig Lookup) argument, the compiler adds to the scope all the characters declared in the parent areas of each parameter .
Even if Y is the "child namespace" of X , they are not related in ADL terms. The first of your parameters is the type defined in the std:: , and the second is a local character (defined in the same namespace as the function itself).
Note that due to the reasons mentioned above, you are most likely to get another error on this line:
std::cout << v << std::endl;
when the compiler cannot find operator<< overloaded for std::vector<double> (because it lies inside namespace X ).
To solve this problem you can use:
using X::operator<<
inside namespace Y or move this overload.
If you are wondering why the foobar example works: because ADL ( Argument dependent search) concerns the parameter area of ββthe functions, not the functions themselves. In foobar ADL code is not used.
source share