Boost logo

Boost :

From: E. Gladyshev (egladysh_at_[hidden])
Date: 2003-09-02 01:54:28


--- "E. Gladyshev" <egladysh_at_[hidden]> wrote:
>
> --- David Abrahams <dave_at_[hidden]> wrote:
> > >>> But indeed allocate/construct/deallocate/destroy is more work than
> > >> ^^^^^^^^^ ^^^^^^^
> > >> Oyeah. These two absolutely don't belong in allocator, period. Do
> > >> any implementations even use them? Allocators exist to provide a
> > >> point of customization for users, but you cannot/should not customize
> > >> these.
> [...]
> > The class getting constructed/destroyed has full control over that or
> > the language is utterly bustificated.
>
> I think construct/destroy can be implemented as non-customizable
> static functions in boost just for convinence.
>
> static template< typename A >
> typename A::pointer construct( A& a, size_t n )
> {
> typename A::pointer p = a.allocate(n)
> try
> {
> p = new(p) A::value_type[n];
> }
> catch(...)
> {
> a.deallocate( p, n );
> }
> return p;
> }
>
> Eugene

Oops,

static template< typename A >
typename A::pointer construct( A& a, size_t n )
{
   [...]
   catch(...)
   {
     a.deallocate( p, n );
     throw;
   }
   return p;
}

Eugene

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com


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