|
Boost : |
From: Anthony Williams (anthony_w.geo_at_[hidden])
Date: 2006-10-06 06:39:59
Bronek Kozicki <brok_at_[hidden]> 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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk