#include <iostream>
#include <string>
class X {};
namespace N
{
std::string to_string(X)
{
return "foo";
}
void foo()
{
std::cout << to_string(X()) << std::endl;
}
}
int main()
{
N::foo();
return 0;
}
Either I stumbled upon one of the many C ++ - lasso that I do not master, or I miss something obvious here.
How can I using std::to_string
reduce the set of names available during unqualified searches to only those that are accessible via ADL? Although I can guess that the problem may be that it is to_string(X)
declared in a different namespace, than X
, I cannot help but notice that without using std::to_string
, it’s N::to_string(X)
just available for N::foo()
using the “normal”, intuitive search rules I'm used to.
source
share