The std namespace is special in C++, so ...
Is this legal C++?
// at global scope
namespace mine {
  namespace std {
    ...
  }
}
I'd call it insane, but is it allowed?
A reference (or non-reference) from the Standard would be appreciated.
The std namespace is special in C++, so ...
Is this legal C++?
// at global scope
namespace mine {
  namespace std {
    ...
  }
}
I'd call it insane, but is it allowed?
A reference (or non-reference) from the Standard would be appreciated.
 
    
    In the reserved names standard 17.4.3.1 (and its sub-paragraphs) I can't find anything that prohibits using std as a nested namespace name. It's not a macro, it's not in the global namespace, and it doesn't seem to meet any of the "external linkage criteria" that would prohibit it.
It appears to be legal (although as you note extremely inadvisable).
 
    
     
    
    The rule in the standard that makes the std namespace "special" is (§17.6.4.2.1 [namespace.std]/p1):
The behavior of a C++ program is undefined if it adds declarations or definitions to namespace
stdor to a namespace within namespacestdunless otherwise specified.
This only applies to the top level namespace.
