From: Anthony Williams (anthony_w.geo_at_[hidden])
Date: 2006-11-03 03:04:55
Roland Schwarz <roland.schwarz_at_[hidden]> writes:
> 2) I have tried to find out if it is possible to implement a mutex
> that is statically initializeable with the additional constraint
> that zero initialization suffices.
> I have provided a prototype that let me believe it really can be
> done. (Such a mutex has the additional benefit that you need no
> explicit memory management.)
boost/thread/win32/basic_timed_mutex.hpp on the thread-rewrite branch provides
a win32-specific statically-initializable-with-zero mutex (that I use as the
basis for boost::mutex on win32). The thing is, it does require initialization
when used with non-static storage duration.
If the constexpr proposal gets accepted into the C++ Standard, we won't have
to worry about this in the future --- constructors that just use constant
expressions can be tagged "constexpr", and used for static initialization.
-- 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