Dec 12, 2017

[C++] defining a namespace inside std is undefined behavior

Defining a namespace inside std is undefined behavior.

Reference:
cppref extending_std

§17.6.4.2.1
The behavior of a C++ program is undefined if it adds declarations or definitions to namespace std or to a namespace within namespace std unless otherwise specified.
A program may add a template specialization for any standard library template to namespace std only if the declaration depends on a user-defined type and the specialization meets the standard library requirements for the original template and is not explicitly prohibited.
[...] A program may explicitly instantiate a template defined in the standard library only if the declaration depends on the name of a user-defined type and the instantiation meets the standard library requirements for the original template.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.