2009/3/16 Matthew Scouten (TT) <matthew.scou...@tradingtechnologies.com>:
> So here is some strange behavior I ran across with BP. A take a look at this
> example code:
>
>
>
> busybox.cpp:
>
>
>
> #include "stdafx.h"
>
>
>
> std::string foo_int   (int    arg) { return std::string("foo(int)
> Called"); }
>
> std::string foo_double(double arg) { return std::string("foo(double)
> Called"); }
>
> std::string foo_bool  (bool   arg) { return std::string("foo(bool)
> Called"); }
>
> BOOST_PYTHON_MODULE(busybox)
>
> {
>
>     bp::def("foo", foo_double);
>
>     bp::def("foo", foo_bool);
>
>     bp::def("foo", foo_int);
>
>
>
> }
>
> ...
>
> Now the order sensitivity is annoying, but I can figure out how to make it
> work right, and then comment the dickens out of the code. The real killer is
> that there does not seem to be any way to force BP to differentiate between
> a bool and an int. The only thing that has worked is to apply a name skew
> (ie: bp::def("foo_bool", foo_bool);). This works, but the users carp at me
> for changing the interface from the underlying library.
>
>
>
> Is there a better work around?

Yes:

1. rename your functions

2. introduce a function in Python, which selects "the right" function,
based on argument type.

> Is this a bug?

Take a look on the following doc:
http://www.language-binding.net/pyplusplus/documentation/functions/registration_order.html

HTH


-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to