ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> boost
boost
Re: [boost] Mini-review request: aligned_storage.hpp
by Fernando Cacciola other posts by this author
Aug 7 2002 2:58PM messages near this date
Re: [boost] Mini-review request: aligned_storage.hpp | Re: [boost] Mini-review request: aligned_storage.hpp
----- Original Message -----
From: "Eric Friedman" <ebf@[...].net> 
To: "'Fernando Cacciola'" <fcacciola@[...].com> ; "'boost developers'"
<boost@[...].org> 
Sent: Wednesday, August 07, 2002 1:01 AM
Subject: RE: [boost] Mini-review request: aligned_storage.hpp


>  I'm not sure if the intent of your proposal is to "Keep It Simple,
>  Stupid", but I have developed far more full-featured aligned-storage and
>  incomplete-type facilities, which may be of interest to the Boost
>  community.
> 
>  They are available in the sandbox:
> 
>    boost/aligned_storage.hpp
>    boost/incomplete.hpp
>    boost/incomplete_fwd.hpp
>    boost/utility/safe_swap.hpp
>    boost/utility/safe_assign.hpp
> 
>  Note, however, the semantics for my boost::aligned_storage varies some
>  from yours (to allow greater genericity of usage):
> 
>    boost::aligned_storage<size_t Size, size_t Alignment = -1>
> 
>  ...where an omitted Alignment (i.e. an Alignment of '-1') provides for
>  maximally-aligned storage, leveraging boost::detail::max_align (which I
>  think BTW should be promoted out of the detail namespace).
> 
>  [rest stripped]

Hi Eric,

I've carefully looked at your aligned_storage.hpp.

If I understood it correctly, it features these two things:

1) Provides a raw buffer which can allocate an object of type T with the
appropriate alignment.
2) Provides a high-level adaptor interface based on placement new which
allows users to treat the aligned buffer as ordinary objects (through
construct_as,get_as,assign_as, destroy_as,etc...)

AFAICT, (2) is built entirely upon (1), so I think that a factorization
might be more adequate.

That is, I think we should keep aligned_storage<>  clean and simple, and
provide the adaptor as another, higher-level class  built upon
aligned_storage.

As for the simple aligned_storage<> , I like the idea of being able to select
maximum or best alignment.
I'm not sure if the interface which takes two integers is good, though; It
does have potential for greater flexibility, but it is also significantly
more obscure for the user (IMHO).
In all the examples of this sort of utility that I've seen, 'size_' is
always 'sizeof(T)' and 'alignment_' is always
'boost::alignment_of<T> ::value'; so, unless a concrete example pops up, I
prefer to parametrize aligned_storage in terms of T + Count (for arrays) + a
tag struct indicating minimum (default) or maximum alignment.

That is, instead of this interface:

template < std::size_t size_, std::size_t alignment_ = -1>  class
aligned_storage ;

I prefer:

struct use_min_alignment ;
struct use_max_alignment ;

template<class T, class align_choice = user_min_alignment, size_t count = 1> 
class aligned_storage ;

P.S: I'm looking also at safe_assign()... but I'm not totally convinced.
Once I have boiled down all the details about it, I'll let you know so we
can discuss it.


Fernando Cacciola
Sierra s.r.l.
fcacciola@[...].com
www.gosierra.com








_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Thread:
Fernando Cacciola
Eric Friedman
Fernando Cacciola
Douglas Gregor
Fernando Cacciola
Douglas Gregor
Itay Maman
David Abrahams
Eric Friedman
Itay Maman
Fernando Cacciola
David Abrahams
Eric Friedman
Douglas Gregor

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved