ADL hits the sweet spot of absolutely critical feature for C++ to be even remotely workable and a horrible anti feature that causes surprising behavior at a distance. So, critical and horrible at the same time. I think things like this are why C++ will lose over time
Recently discovered this behaviour, I think I had just always assumed that e.g. operator<< was declared linked to the class, rather than just in a randomly searched namespace.
We were using the fmt library, and had `using namespace fmt` so that we could just call print(), format() directly. Suddenly, some of our calls (all that used std::strings as arguments) started failing as "ambiguous". We traced it to an updated dependency that... now included <chrono>. chrono includes format as part of it's formatting capabilities, so the compiler knows that the namespace object exists.
I find it crazy that it's impossible to bypass and say "no, I really do want this name". This seems to entirely defeat the point of namespaces. Now we have to have fmt:: sprinkled everywhere.
ADL hits the sweet spot of absolutely critical feature for C++ to be even remotely workable and a horrible anti feature that causes surprising behavior at a distance. So, critical and horrible at the same time. I think things like this are why C++ will lose over time
Recently discovered this behaviour, I think I had just always assumed that e.g. operator<< was declared linked to the class, rather than just in a randomly searched namespace.
We were using the fmt library, and had `using namespace fmt` so that we could just call print(), format() directly. Suddenly, some of our calls (all that used std::strings as arguments) started failing as "ambiguous". We traced it to an updated dependency that... now included <chrono>. chrono includes format as part of it's formatting capabilities, so the compiler knows that the namespace object exists.
I find it crazy that it's impossible to bypass and say "no, I really do want this name". This seems to entirely defeat the point of namespaces. Now we have to have fmt:: sprinkled everywhere.
Fuck'n language.
In C# you can do `using XXX = qualified.XXX`. Is there nothing like that in C++?