From: Juan Pedro Bolivar Puente on

>
> I like your solution, except that in C++03 you'll hit a road bump if the
> params class has a non-trivial constructor. In my solution I lay the
> burden of writing all non-trivial constructors on params_XXX classes
> that can just call the correct non-trivial constructor of params class.
> In you solution it's just not possible.
>
> In C++0x on the other hand, you'll be able to inherit constructors, so
> your solution will work great there.
>

I don't really understand what is the problem in that sense. All our
solutions are calling the copy constructor in the scope of the most
inherited class in the params hierarchy. I don't think that lacking
constructor inheritance causes more problems here than without the
cloning facility.

JP

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Andy Venikov on
Juan Pedro Bolivar Puente wrote:
<snip>
> I don't really understand what is the problem in that sense. All our
> solutions are calling the copy constructor in the scope of the most
> inherited class in the params hierarchy. I don't think that lacking
> constructor inheritance causes more problems here than without the
> cloning facility.

For example,
if original structure has a non-default
constructor

struct params
{
protected:
int a_, b_, c_;
public:
params (int a, int b, int c) : a_(a),
b_(b), c_(c)
{}
};

Then currently all derived params_XXX already must have a corresponding
delegating constructor, like this:

struct params_1 : public params
{
protected:
int d_;
public:
params_1(int a, int b, int c, int d)
: params(a, b, c), d_(d)
{}
};

In the solution where the clonable class derives from params_1, you must
supply a corresponding delegating constructor, which is hard to do
generically in C++03. If you can wedge clonable in between the params
and params_1, then you don't have to worry about creating your own
constructor.

>
> JP
>

Andy.

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]