davisking/dlib

[Bug]: Conflicts with other codes due to "using namespace std;" in header files

ChristopheDumeunier opened this issue · 3 comments

What Operating System(s) are you seeing this problem on?

Linux (x86-64)

dlib version

19.24

Python version

3.12

Compiler

GCC 13.2

Expected Behavior

No response

Current Behavior

Several headers of dlib declare "using namespace std;". It creates conflicts with other codes having functions/classes in their own namespace having the same name than the std lib and having the same practice.

It's usually considered a very bad practice in headers: stackoverflow.com/questions/1452721/whats-the-problem-with-using-namespace-std

Steps to Reproduce

/* This code reproduces the problem */
namespace my_namespace { template struct numeric_limits {}; }
using namespace my_namespace;

include <dlib/optimization.h>

int main(){ return 0; }

Anything else?

No response

I've been checking the header files and, indeed, there are quite a few instances of using namespace std;. However, none of them is in the global scope. So they shouldn't interfere.

Either way, if @davisking is OK, I can remove all those instances and sprinkle a bit of std:: here and there.

@ChristopheDumeunier could you try and see if #3016 fixes it?