[C++-sig] [boost::python] Unresolved overloaded function - methods with same name
yardbird
yardbird at nerdshack.com
Fri Oct 27 17:48:50 CEST 2006
Hello,
I have a problem with getters/setters methods with the same name which both
return cont/non-const reference to a class' data member. For instance:
struct Foo {
Foo(int x) { b = x; }
int const& get_b() const { return b; }
int & get_b() { return b; }
private:
int b;
};
// Wrapper code
BOOST_PYTHON_MODULE(my_module)
{
class_<Foo>("Foo", init<int>())
.def("get_b", &Foo::get_b);
}
When I try to build this it seems like it cannot decide whether it should use
the const or non-const method to access the member. The error I get is
something like:
[...]no matching function for call to [...] ::def(const char [6], <unresolved
overloaded function type>,[...]
I know I could just make "b" public and then use .defreadonly/.defreadwrite to
access it, but I would like to keep unaltered the original layout of the
class.
Sorry if this is a stupid question, I looked at the documentation and tried to
use "return_internal_reference<>()" and the likes but I really could not
figure it out.
Thanks very much,
Francesco
More information about the Cplusplus-sig
mailing list