When writing code like this
std::vector<int> test;
std::find(test.begin(), test.end(), 5);
My IDE (Microsoft Visual Studio 2017 with the Resharper plugin ) tells me that the namespace qualifier on the second line is redundant and the code can be rewritten like this:
std::vector<int> test;
find(test.begin(), test.end(), 5);
It compiles just fine. Note that at no point do I use using namespace std
or using std::find
. This does not apply only to the std namespace, I've seen it on other occasions.
Under which exact circumstances is omitting the namespace qualifier allowed, provided no using
was used? Where in the language standard is this defined and what's the rationale for it?
After some testing my assumption is, that if one parameter of the function lies in the same namespace as the function, the namespace of the function is automatically inferred, but I would like to see some official reference.