Extending the std namespace with reverse code

A bit of background:

The extension namespace stdis undefined -behavior (UB), unless it is a template specification [ 1 ]:

This is undefined behavior for adding declarations or definitions to the namespace std or any namespace nested in std, with a few exceptions noted below

There are also questions about SO, which also say that it is UB and a bad idea [ 2 , 3 ].

We use boost::tr1on platforms that do not have support tr1(for example, WinCE, WM). Boost does just that: introduces its own implementation into std::tr1, if tr1not provided.

For example, in boost/tr1/memory.hpp:

namespace std{ namespace tr1{ 
   using ::boost::bad_weak_ptr;
   using ::boost::shared_ptr;
   ...
} }

My questions:

  • , UB, boost::tr1 , tr1?

  • , backports std, , backported ?

  • , boost::tr1 std std::tr1?

+6

All Articles