Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-02-04 08:00:37


From: "Ralf W. Grosse-Kunstleve" <rwgk_at_[hidden]>
>
> I did not use boost::shared_array to implement the shared_plain<T> type
because
> one of our requirements is that one reference count can be used to manage
> multiple types. This is required in the context of in-place fast Fourier
> transforms. I.e. an array that starts out as
shared_plain<std::complex<double>
> > ends up as shared<double> after the Fourier transformation or vice
versa. Of
> course, constructing an array with type T and destructing it while
thinking of
> it as containing element types U could potentially lead to disasters. To
> provide a certain degree of protection type casts are therefore only
allowed
> for element types with trivial destructors. This is managed through type
traits
> that can be specialized by the user.

On most platforms, if you reinterpret_cast a shared_array< complex<double> >
to shared_array< double >, it will still destroy itself properly. (magic!)


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