Actions

icon Post
text/html Subscribe
text/html Unsubscribe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vsipl++] proposal: a typed alloc_align()


  • To: "Nathan (Jasper) Myers" <ncm@xxxxxxxxxxxxxxxx>
  • Subject: Re: [vsipl++] proposal: a typed alloc_align()
  • From: Mark Mitchell <mark@xxxxxxxxxxxxxxxx>
  • Date: Thu, 03 Nov 2005 11:41:28 -0800

Nathan (Jasper) Myers wrote:

> I'm wrong.  If you provided an op delete(void*, vsip::impl::align&)
> then (5.3.4 para 19) the compiler would generate a call to it if 
> the constructor were to throw.  However, there's no syntax for a 
> delete-expression to call it, and anyway no mechanism to tell (e.g.) 
> std::auto_ptr<>() to use the right op delete overload.

Right, my suggestion was to have:

1. The overloaded placement-new operator for the allocation.

2. The placement-delete operator to handle the exception.

3. An ordinary functon ("vsip::impl::free_aligned") to call to
deallocate the memory.  This would probably be implemented in terms of
the placement-delete operator, or vice versa.

There are other potentially bad aspects of my idea, though.  For
example, for a class type with a destructor, the compiler will allocate
extra storage to record how many entries are in the array; we may not
want that extra storage.  The extra storage comes at the start of the
array, and would mess up the intended alignment of the array elements.

-- 
Mark Mitchell
CodeSourcery, LLC
mark@xxxxxxxxxxxxxxxx
(916) 791-8304