by clpm4j · 4y ago · 0 comments
Yup that's the one I mentioned. It was just an example though, there are lots of others.
> am I supposed to avoid using the name `load` or qualify it with the namespace path
The latter. i.e. you should write serialize::load() (or ::serialize::load()) unless you intend ADL to occur.
> Everything seemed to compile and work fine the last time I touched this codebase.
Yeah I wasn't claiming it wouldn't compile right now. The problem is that it has a higher risk of changing behavior in the future. In this example, if this function is ever introduced:
namespace kj { auto load(InputStream &stream) { ... } }
then suddenly that function will get called instead of yours, which may or may not result in a compiler error.It's not exactly the biggest footgun in C++, but "well-written" C++ code tries to be careful about pitfalls like these.