|
Boost : |
From: Corrado Zoccolo (czoccolo_at_[hidden])
Date: 2007-11-18 13:00:34
Hi Giovanni
On Nov 18, 2007 1:59 PM, Giovanni Piero Deretta <gpderetta_at_[hidden]> wrote:
>
> Maybe you can use SFINAE to detect if a class implements operator new.
> I'm not sure if
> it can be done for operator new, it certainly can be done for other
> member functions.
>
> --
> gpd
I think SFINAE is not enough to replicate faithfully the rules employed by
the compiler to select the which operator new is called for an expression
like new T(a1,..,an) . It will look not only in T, but also in its base
classes.
I solved differently, by writing an adapter around in_place_factory (that
can be found attached).
Basically, I create a set of classes typed_out_of_place_factory##N, each
inheriting from typed_in_place_factory##N, that provide me the correct apply
overload, and a template function to ease the conversion (out_of_place:
typed_in_place_factory##N -> typed_out_of_place_factory##N).
The only drawback of this, w.r.t. changing in_place_factory to provide this
behavior, is that I have to include it always, so the preprocessor magic
overhead is always paid. The other solution, the client code would include
it only when it is actually used.
-- __________________________________________________________________________ dott. Corrado Zoccolo mailto:zoccolo_at_[hidden] PhD - Department of Computer Science - University of Pisa, Italy -------------------------------------------------------------------------- The self-confidence of a warrior is not the self-confidence of the average man. The average man seeks certainty in the eyes of the onlooker and calls that self-confidence. The warrior seeks impeccability in his own eyes and calls that humbleness. Tales of Power - C. Castaneda
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk