[vsipl++] proposal: a typed alloc_align()
Nathan (Jasper) Myers
ncm at codesourcery.com
Thu Nov 3 19:30:28 UTC 2005
On Thu, Nov 03, 2005 at 10:48:36AM -0800, Nathan (Jasper) Myers wrote:
> On Thu, Nov 03, 2005 at 07:58:00AM -0800, Mark Mitchell wrote:
> > 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.
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.
Also, if the user were also to provide a placement delete operator
that happens to be ambiguous with ours, then in the event of an
exception the memory would just leak. (I hope the compiler would
warn about this, but I have no reason to expect so; placement delete
is rarely used, for obvious reasons.)
Nathan Myers
ncm
More information about the vsipl++
mailing list