Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2003-08-21 10:07:04


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.

HTH,

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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