
6 Oct
2006
6 Oct
'06
11:53 a.m.
Bronek Kozicki wrote:
What's wrong with simple:
template <typename T> struct wrapper { static T data; };
template <typename T> T wrapper<T>::data;
template<C> void foo(C arg) { bar<C>& abar = wrapper<bar<C> >::data; }
... which will trigger static (thread-safe) initialization.
This doesn't solve the initialization order problem, the primary reason for using local statics in the first place.