Adding types to the std namespace

Solution 1:

Only specializations are allowed. So for example, you are allowed to specialize std::numeric_limits for your type. And this of course must happen in namespace std::. But your typedef isn't a specialization so that's causing undefined behavior.

Solution 2:

No ... part of the point of a namespace is to prevent name collisions on upgrade.

If you add things to the std namespace, then your code might break with the next release of the library if they decide to add something with the same name.

Solution 3:

[C++11: 17.6.4.2.1/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.

Solution 4:

You should use your own namespace as adding code to the standard library will only confuse the users that will look online for informations about that addition.

All that is in std should be only the standard library and nothing else.