I have been successfully using cxx-prettyprint: A C++ Container Pretty-Printer to log container values. (See also Pretty-print C++ STL containers) It\'s working lik
This is covered by [namespace.std]/1 in the standard (which is quoted in the question but reproducing it here as it is also the answer):
The behavior of a C++ program is undefined if it adds declarations or definitions to namespace
std
or to a namespace within namespacestd
unless otherwise specified.
There isn't any "otherwise specified" for overloads of operator<<
for new user-defined types.
So the behaviour is just undefined (with no diagnostic required).
In practical terms it seems like that either the code will work or it won't, but as with all UB we should be careful not to rule anything else out.