[C++-sig] Avoid Implicitly conversion for non direct conversion

Renato Araujo renatox at gmail.com
Wed Jan 6 14:10:02 CET 2010


Hi thanks for you help,

On Wed, Jan 6, 2010 at 4:59 AM, Hans Meine <hans_meine at gmx.net> wrote:
> On Dienstag 05 Januar 2010, Renato Araujo wrote:
>> I would like to know if is possible to avoid this level of conversion
>> and tell to boost.python only try the direct conversion,
>
> Not as far as I know.
>
>> because this
>> make the functions call slower then normal calls,
>
> But only if you pass objects that need to be converted, right?
Yes but this is the user level I would like to avoid this.


>
>> and some times cause
>> a lot of problems in my classes.
>
> Details?


I'm working on PySide (python bindings for Qt), and I have a lot of
classes and a lot of implicitly conversions.

Example:

I have a class QVariant (Docs:
http://doc.trolltech.com/4.6/qvariant.html) with many constructos, adn
each type has your implicitly conversion rule.
One example is QCorlor (Docs:
http://doc.trolltech.com/4.6/qcolor.html) this is implicitly
conversible from "int".

Then when I create a QVariant(1) (passing int as argument)
boost.python call the QVariant(QColor) constructor. I think this
happening because boost.python try the implicitly conversion before
verify the other basics signatures. This is one of the case I have a
lot of others because I have more then 100 classes and more then 200
implicitly conversions rules, it's almost impossible to me,  manager
this if the conversion can happen in every class level.

>
> You might have problems with overloaded functions, in which case Troy's
> recently suggested BPL extension would most likely help.  (I am looking
> forward to its integration).

Where I can get more info about this I searched in ML but I did not
find any info related.

>
> Ciao, /  /                                                    .o.
>     /--/                                                     ..o
>    /  / ANS                                                  ooo


Thanks


More information about the Cplusplus-sig mailing list