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: vsipl++@xxxxxxxxxxxxxxxx
  • Subject: Re: [vsipl++] proposal: a typed alloc_align()
  • From: "Nathan (Jasper) Myers" <ncm@xxxxxxxxxxxxxxxx>
  • Date: Thu, 3 Nov 2005 10:48:36 -0800

On Thu, Nov 03, 2005 at 07:58:00AM -0800, Mark Mitchell wrote:
> Jules Bergmann wrote:
> 
> >     float* foo = alloc_align<float>(align, elem);
> 
> Note that you could spell this like:
> 
>   new(vsip::impl::align(16)) float[elem]

Be careful.  Conventionally, storage obtained via op new is 
released via op delete.  The compiler enforces that: if you said 
"new (vsip::impl::align (16)) vsip::Fft<>", for example, and the
Fft<> constructor threw an exception, the implicit code generated
by the compiler would call ::op delete itself.

As a library, we can't replace ::op delete ourselves; that choice
is reserved to the main program.

This inflexibility is an unfortunate legacy of early C++, although 
to this day I don't know how it might have been done better.
Probably any such improvement would involve templates.

Nathan Myers
ncm