"Gianni Mariani" <gi*******@mariani.ws> wrote...
Victor Bazarov wrote: "Gianni Mariani" <gi*******@mariani.ws> wrote...
I'm developing a factory template that supports placement new and one of
the methods I need to provide is a copy constructor. The question is,
how do I make the template generic for implementations that may not
support the copy constructor.
As you will be able to tell from this response, I don't exactly
understand why you need to dance around this. Just document the fact that the type
used with your template has to be copy-constructible and that's all.
A type may be intentionally made _not_ copy-constructible. If you allow
to use your factory that will work around that, you're circumventing the
intention of the designer of that type, no?
Well, it's a "generic" factory object that we might want a placement
copy constructor method or not depending on if the type is copy
constuctible.
The factories are placed in a registry which contain all factories for
implementations that have the factory interface - wether they are copy
constructible or not.
The design is a generic interface to *structing - including support for
PIMPL. The issue that arises is what to do for copy constructors.
One possible solution is to leave it up to when the factory is
instantiated and let the implementor specify wether the implementation
is copy constructible. Still, it would be neat if the default was
"natural".
Ah... Well, it sounds like you're trying to create something a bit
too generic (again, it's possible that I am not fully appreciating
the possibilities such a solution provides).
I suppose that due to my incomplete comprehension of the problem you
are trying to solve I cannot see a clear solution for it. Sorry to
have wasted your time and bandwidth.
Speaking of placement and factories, it does sound a bit like you're
trying to produce a memory management mechanism. What if you looked
at the existing ones? I cannot claim any deep knowledge of those on
the market, but maybe a search on Google could help you find what is
out there.
In any case, best of luck!
Victor