These two are not equivalent. In the first case, the bar namespace is imported into the foo namespace, so for each bar::x you can access it as foo::x . In the last namespace, bar imported into the global namespace (or the namespace that wraps both), and can be accessed as ::x .
I would recommend always choosing the narrowest solution for you. Even in terms of including the namespace only in the function that you really need. Therefore, if in doubt, go to the first.
source share