1

I just saw in some DLib code, in a .cpp file a thing like that:

#include <stdio>

namespace {

  using namespace std;

  void foo() {
    ::std::vector<int> my_vector;
  }
}

Is there a reason we specify ::std:: in front of our vector we imported from std already ?

baptiste
  • 1,107
  • 2
  • 15
  • 30
  • 2
    IMO these are bad dupes, AFAICT OP is asking whats the point of having *both* `using namespace std;` *and* `::std::` – Borgleader Jan 23 '18 at 17:04
  • 3
    Even if you `use namespace std`, you might shadow the names locally. The double colon forces access to the namespace. – Barmar Jan 23 '18 at 17:06
  • from https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice - this explictly picks vector from std rather than any other namespace that might be floating around – UKMonkey Jan 23 '18 at 17:06

0 Answers0