Assuming the same names end up being found the efficiency is the same: independent of how the function name is spelled the same function is being called. The main difference is how names are being located. Using full qualification prevents, e.g., argument-dependent look-up and is, thus, easier to understand.
Of course, when you actually do have a customization point you'd want to use an unqualified call for argument-dependent look-up to kick in. If there is no need for a default implementation for the customization point there is no need to have a using
declaration or even a using
directive. Incorrect use of customization points can have a negative performance impact. For example, when using swap()
you do not want use the name qualified:
template <typename T>
void some_function(T& v1, T& v2) {
std::swap(v1, v2); // <--- this is bad! It uses the default implementation
using std::swap; // make a default implementation visible
swap(v1, v2); // <--- this is better: if it exists uses T's swap()
}
If T
has a customized swap()
it is likely more efficient than std::swap()
which may cause copies of the values v1
and v2
. With move-enabled types T
the difference isn't as bad but it could still be substantial. Of course, the issue here isn't the use of qualification or no qualification but rather the fact that the two ways to call a function may result in different functions being found depending on whether swap()
is overloaded for T
.
BTW, if you are interested in efficiency, do not use std::endl!