C++ namespaces prevent collisions, but what if the name of the namespace itself collides? Example:
#include <cstdlib>
namespace atoi {
int foo() {return 42;}
}
Question: can I reliably avoid the collision by namespace Atoi
? That is, does C++ protect my use of a mixed-case namespace name like Atoi
? Or is a mixed-case namespace name like Atoi
liable to be trampled by a future C++ standard, technical specification (TS), Boost library, compiler, toolchain, etc.?
Of course, I do not really intend namespace atoi
or namespace Atoi
for practical code. Those are merely for illustration (since atoi
happens to be a name the C standard library uses). What I really intend is namespace my
, preferably in lower case but if necessary in mixed case as namespace My
. Your answer regarding atoi
and Atoi
could influence my choice between my
and My
. This is why I ask.
I notice that Stroustrup prefers mixed-case namespace names. I also notice that examples in sect. 10.3 of the C++17 standard (draft here) avoid lower-case namespace names.
See also this related question.