
6 Oct
2006
6 Oct
'06
10:39 a.m.
Bronek Kozicki <brok@spamcop.net> writes:
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.
Yes, but you only get one global instance for each type T, which defeats the point of making it a function-local static. Anthony -- Anthony Williams Software Developer Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk