H
Hendrik Schober
Hi,
I need something like this:
class X {
private:
struct Impl_ {
virtual ~Impl_() {}
virtual Impl_* clone() const = 0;
};
Impl_* impl_;
public:
// ...
};
'X' should have value semantics, so '*impl_'
must be cloned when 'X' is copied. I know
how to do this and I have don it a couple
of times. And that is bothering me. I would
rather have a smart pointer that supports
cloning semantics and use this whenever I
run into this pattern.
Is there a smart pointer out there doing
this or do I have to roll my own?
Note: Ideally, it would come in just one
header file. I do not want to add a whole
new library to get s cloning smart pointer.
I have full control over 'X' and 'X::Impl',
so I could actually make them fit some ready-
made smart pointer if I find one.
Schobi
--
(e-mail address removed) is never read
I'm Schobi at suespammers dot org
"Sometimes compilers are so much more reasonable than people."
Scott Meyers
I need something like this:
class X {
private:
struct Impl_ {
virtual ~Impl_() {}
virtual Impl_* clone() const = 0;
};
Impl_* impl_;
public:
// ...
};
'X' should have value semantics, so '*impl_'
must be cloned when 'X' is copied. I know
how to do this and I have don it a couple
of times. And that is bothering me. I would
rather have a smart pointer that supports
cloning semantics and use this whenever I
run into this pattern.
Is there a smart pointer out there doing
this or do I have to roll my own?
Note: Ideally, it would come in just one
header file. I do not want to add a whole
new library to get s cloning smart pointer.
I have full control over 'X' and 'X::Impl',
so I could actually make them fit some ready-
made smart pointer if I find one.
Schobi
--
(e-mail address removed) is never read
I'm Schobi at suespammers dot org
"Sometimes compilers are so much more reasonable than people."
Scott Meyers