boost::python - double vs. int - unexpected behavior

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? cheers dom -----[ Domenico Andreoli, aka cavok --[ http://filibusta.crema.unimi.it/~cavok/gpgkey.asc ---[ 3A0F 2F80 F79C 678A 8936 4FEE 0677 9033 A20E BC50 [Non-text portions of this message have been removed]

On Thu, Aug 21, 2003 at 02:25:24AM +0200, cavok@filibusta.crema.unimi.it wrote:
[Non-text portions of this message have been removed]
damn... as if it was not text... here it is.
#include

cavok@filibusta.crema.unimi.it 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

On Thu, Aug 21, 2003 at 11:07:04AM -0400, David Abrahams wrote:
cavok@filibusta.crema.unimi.it 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
participants (2)
-
cavok@filibusta.crema.unimi.it
-
David Abrahams