The code at my new workplace accesses namespaces using a seemingly redundant scope resolution at the start. For example, ::std::vector<int>
instead of std::vector<int>
.[1] I have never seen namespace access being done this way before.
One somewhat contrived scenario I could think of is when some namespace ns
declares a nested namespace std
, which too has a vector
(in this example). Then the "additional" ::
at the left ensures that the global std::vector
is being used, not the local one. However, this is unlikely to be the reason given that our code goes through a rather elaborate review process making it almost impossible for anyone to introduce a new std
namespace.
Are there any other scenarios where this could make a difference?
[1] I asked a few senior developers in the team to explain this to me, but they only have a vague idea why this "convention" is being used. The earliest developers who wrote the code left the team years ago, and nobody asked them about it before they left.