Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-08-24 13:39:16


Ion Gaztañaga wrote:

> Peter Dimov wrote:
>> the author of X may have accidentally omitted the initialization of cn_.
>> Without a default constructor, this doesn't compile and one needs to
>> explicitly choose between
>>
>> X(): cn_( &mx_ ) {}
>>
>> and
>>
>> X(): cn_( 0 ) {} // no checking
>
> What about...
>
> template<Mutex>
> class condition
> {
> condition();
> explicit condition(any_mutex_type);
> explicit condition(mutex_type& m);
> //...
> };

This is possible, but the default constructor still allows you to forget to
associate the condition with a mutex:

    X() {}

any_mutex vs 0 is a style issue; I prefer to use an old-fashioned way if it
does the job as this is what the majority of the audience expects and
understands, as un-Boost-y this may sound. :-) Not a big deal though.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk