Boost logo

Boost Users :

From: cavok_at_[hidden]
Date: 2003-08-21 18:28:04


On Thu, Aug 21, 2003 at 11:07:04AM -0400, David Abrahams wrote:
> cavok_at_[hidden] writes:
>
> > hi,
> >
> > i attached a simple example that shows the following behavior:
> >
> > $ python
> > Python 2.2.3+ (#1, Aug 10 2003, 10:11:23)
> > [GCC 3.3.1 (Debian)] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
> >>>> import test
> >>>> a=test.A()
> >>>> a.f(3)
> > double
> >>>> a.f(3.8)
> > double
> >>>> a.f(int(3))
> > double
> >>>>
> > $
> >
> > well, doesn't it look weird?
> >
> > any idea on how i can get the correct c++ method called?
>
> Reverse the order of the .def calls -- Boost.Python prefers later defs
> and Python ints match C++ double args, but not vice-versa. Yes, this
> really should be documented. One day we will have "best match"
> overloading and this issue will disappear.
>
it is very nice to know this, indeed i expected the "best match"
approach, even if nobody told me about it.

i made several tests and i can't believe i have always used the wrong order!

many thanks

cheers
dom

-----[ Domenico Andreoli, aka cavok
 --[ http://filibusta.crema.unimi.it/~cavok/gpgkey.asc
   ---[ 3A0F 2F80 F79C 678A 8936 4FEE 0677 9033 A20E BC50


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net