Boost logo

Boost :

From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2001-10-25 16:36:10


----- Original Message -----
From: <brianjparker_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Tuesday, October 23, 2001 11:45 PM
Subject: [boost] Re: Several useful utility classes uploaded

> --- In boost_at_y..., "Fernando Cacciola" <fcacciola_at_g...> wrote:
> >
> > [SNIP]
> >
> > Please, take a look at: aligned_storage.hpp (and
> > aligned_storage_detail.hpp) in
> >
> > http://groups.yahoo.com/group/boost/files/class%20optional
> >
> > I believe this is exactly the same that you are presenting here.
> >
> > Let me know what do you think.
> >
> > Regards,
> >
> > Fernando Cacciola
> > Sierra s.r.l.
> > fcacciola_at_g...
> > www.gosierra.com
>
> Yes, you have faced exactly the same alignment problem as I have; the
> fact that at least two of us have had to solve the same problem

In fact, Douglas Gregor faced this too in his stack based variant class.

> is a
> good existence proof for the need for this functionality to be
> available in the language!
Agreed.

> (actually, as well as the stack_allocator,
> hinted_node_allocator and valunion classes that I have submitted, I
> have also needed this functionality in several other classes that I
> have developed over the years).
>
> The best solution, I think, given that the problem cannot be
> completely solved in current ISO C++, would be a language change that
> added a standardised alignment_of() and #pragma align that worked on
> members of structures and in templated code.
>
I haven't tought about the core issues involved.

> Failing that, however, a second best solution is to have a standard
> (or, initially, Boost) library class that could be guaranteed to work
> on all tested platforms (using platform-specific implementations if
> necessary).
>
Agreed

> Your alignment_alias<T>::type appears to be a more sophisticated
> implementation than my alignment_traits<T>::align_t and may do a
> better job, assuming that boost::alignment_of<>::value is accurate
> which it is not guaranteed to be.

The core of alignment_alias<T> was borrowed from Doug's stack based variant;
so it isn't really *my* implementation.

> (minor note: I see that your list of base types from which to choose
> doesn't include a POD- I had the vague impression that some C++
> implementations can give a structure a different alignment to
> everything else, so it may be prudent to add one to your list).
>
Off the top of my head I think this isn't necessary, but I'll think about
it...

> My aligment_traits<T>::align_t class is more conservative and
> optimised for small types- it may produce a larger alignment than
> required. Maybe some tests are needed on different platforms to see
> which approach works best.
>
I see. I need to look closer to your implementation.

> In any case, I think that one of these classes or something like it
> should be added to Boost.
>
Certainly!

> Do you agree that boost::alignment_of<T>::align_t would be the best
> way to integrate it into Boost?
>
Partially.
If alignment_of<> didn't existed, and we were creating it, yes, I think
I'll put 'align_t' there.
But, given that alignment_of<> is already in use, I'm not sure.
We need to know what other boosters think about this.

Regards,

Fernando Cacciola
Sierra s.r.l.
fcacciola_at_[hidden]
www.gosierra.com


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