Unfortunately, in C ++ 03 there is nothing like dynamically initializing (and destroying) the local resources of a stream (which know nothing about threads).
In C ++ 11, the thread_local storage keyword allows dynamic initialization at the expense of the working environment (basically, equivalent to having a local static stream variable) and therefore can be used without types with constructors.
In C ++ 11, the constexpr constructor can be called for static initialization and therefore must be compatible with the __thread specifier if your compiler implements it.
source share