From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-01-28 14:50:03
From: "Douglas Gregor" <gregod_at_[hidden]>
> On Monday 28 January 2002 02:12 pm, you wrote:
> > > But how would function<> ensure the proper
> > > alignment for the function object type?
> > That shouldn't be hard if we wanted it. After all, we have
> > 'boost::alignment_of', Fernando Cacciola's "aligned_storage.hpp"
> > in the vault, I believe), and Andrei's paper -
> > http://www.oonumerics.org/tmpw01/alexandrescu.pdf - seems to provide a
> > solution as well.
> All solutions require knowing all of the types that storage must be
> with in advance. It works quite well for, e.g., a bounded variant class
> as those written by Brian Parker and Andrei Alexandrescu), but any
> variant (such as boost::any or boost::function) won't benefit because they
> don't haven't anything to align with.
The current alignment solutions don't work in their current form, f.ex.
aligned_storage<> needs the type beforehand.
But wouldn't it be possible to implement (using aligned_storage<> as a
template<class T> (T|void) * placement_allocate(unsigned char *,
which then could be used by function<>:
operator= (F f)
if(void * p = placement_allocate<F>(small_string_buffer, 16))
// new F(f)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk