[C++-sig] implicitly_convertible / virtual base class

Achim Domma achim.domma at syynx.de
Mon Jun 3 23:48:34 CEST 2002


> -----Original Message-----
> From: c++-sig-admin at python.org [mailto:c++-sig-admin at python.org]On
> Behalf Of David Abrahams

> > Wouldn't it make sense to have the possibility to specify at the
> > def_init function that a certain ctor should be used for implicit
> > conversion?
>
> It might. In your case, it's not strictly equivalent unless
> you've declared
>
>     class_<DrawableStrokeColor, bases<DrawableBase> >
>                                 ^^^^^^^^^^^^^^^^^^^
>
> since the best we could do would be to generate
> implicitly_convertible<DrawableBase,Drawable>() automatically.

I realized this solution some minutes after sending the mail. First I
thought I would have to write an implicitly_convertible for each class,
derived from DrawableBase. But with 'bases<DrawableBase> defined and a
conversion from DrawableBase to Drawable it works fine now. This solves most
of my problems.

> Or, we could define
>
>     template <class T>
>     def_implicit(args<T>);

I would prefer this one. I have no problem writing down that the ctor should
be available for implicit conversion, but it would be much more intuitive to
do it directly on the class, than to specify it somewhere else via
implicitly_convertible.

> Oh, BTW, patches to implement this would be welcome ;-)

I'm developing in C++ for some years now, but I fear it's not good enough
for boost. Anyway, if you think it's not to hard to do, I would try it at
least. Could you give me a starting point?

Achim







More information about the Cplusplus-sig mailing list