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-04-25 14:41:30

Thorsten Ottosen <nesotto <at>> writes:

> Joaquin M Lopez Munoz skrev:
> >
> > Yep, why can't you just define null guard as
> >
> > struct null_guard:boost::multi_index::detail::scope_guard_impl_base{};
> the ?: operator seem to require that the second argument can be
> converted to the type of the first argument.

I might be missing something, but I think tou can simply
write the following to circumvent the problem:

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

Does this work? 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.

> > Unrelated to your particular problem, is this auto_buffer class
> > of yours part of Boost or a private project? If the former, we
> > should think about moving scope_guard to boost/detail/ where
> > implementation bits common to several libs inhabit.
> That's a good idea. I'm using it for an upcomming library
> called Boost.AutoBuffer.
> I'm confident that other boost libs also use it.

I've just made a global search and the only other lib using
it is Signals2, inside a detail component of yours (the one you
intend to promote to official lib status, I presume). I'll
add this move to boost/detail/ to my todo list.

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