Boost logo

Boost :

Subject: Re: [boost] [multiindex] internal scope_guard has changed access from public to protected
From: Joaquin M Lopez Munoz (joaquin_at_[hidden])
Date: 2010-05-29 06:41:56

Thorsten Ottosen <nesotto <at>> writes:
> Thorsten Ottosen skrev:
> >
> > Joaquin M Lopez Munoz skrev:
> >
> >> Thorsten Ottosen <nesotto <at>> writes:
> >> Additionally, why are you doing the
> >> guard selection on run time? boost::has_nothrow_copy<T>::value
> >> is a compile-time value so you can select the exact
> >> type of the guard (null or otherwise) with some Boost.MPL.
> >
> > Well, I'm lazy, so I didn't want to implement the functionality twice
> > with and without the guard. IMO the code is very clear with this macro.
> > I think the optimizer has no problem removing the empty guard.
> It seems to me that creating a null-guard conditioned on some
> compile-time value is quite common in containers that copy elements
> around.
> Would it not be possible to add a bool template parameter to
> make_obj_guard() such we can simply write
> scope_guard g = make_obj_guard<some_condition<T>::value>(...);

Yep, this seems like a general enough functionality to be
included in scope_guard.hpp. I'd prefer to leave make_obj_guard
like it is and add an additional


(note the _if) for your use case, which creates a null_guard
if the condition is not true.

Would you like to do the addition yourself and commit the
changes to the trunk? I'm quite busy these days to do it

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo

Boost list run by bdawes at, gregod at, cpdaniel at, john at