Boost logo

Boost :

Subject: [boost] [multiindex] internal scope_guard has changed access from public to protected
From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2010-04-23 08:36:23


Hi Joaquín,

I'm using the scope_guard from multi_index/detail/scope_guard.hpp.

It seems like a revision has made the destructor and copy-constructor
protected instead of private. This is in some sense more idiomatic, but
it breaks a use that I have in my upcomming auto_buffer class. Basically
I'm only constructing a scope_guard object when I know the code can
throw, otherwise I construct a "null" scope_guard which is simply
an instance of scope_guard_impl_base.

Here's the code:

     namespace auto_buffer_detail
     {
         typedef boost::multi_index::detail::scope_guard_impl_base
null_guard;
     }

#define BOOST_AUTO_BUFFER_CONSTRUCTOR_SCOPE_GUARD() \
     boost::has_nothrow_copy<T>::value ?
boost::auto_buffer_detail::null_guard() : \
                            boost::multi_index::detail::make_obj_guard(
*this, \
                                  &auto_buffer::deallocate, \
                                  buffer_, members_.capacity_ )

and use it like so:

             boost::multi_index::detail::scope_guard guard =
                 BOOST_AUTO_BUFFER_CONSTRUCTOR_SCOPE_GUARD();
             ...
             guard.dismiss();

Any chance you make the two members public again?

-Thorsten


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