[C++-sig] Re: yet another: TypeError: No to_python (by-value) converter found for C++ type:
David Abrahams
dave at boost-consulting.com
Tue Aug 24 10:37:39 CEST 2004
"tALSit de CoD" <talsit at talsit.org> writes:
> YES!!
> Thanks heaps, that solved it perfectly...
> I have been bashing my head a bit on that one... couldn't quite figure it
> out. I don't completely comprehend templates, and the wierd and wonderful
> way that it works...
>
> Now, just a quicky:
> If i have two class methods:
> class A {
> public:
> const std::string & getName () { return m_name; }
> private:
> std::string m_name;
> };
>
> class B {
> public
> const A * getA () const { return m_a; }
> A * getA () { return m_a; }
> private:
> A * m_a;
> };
>
> How do i wrap that method? I need them both there, but when i try to wrap
> it like this:
>
>
> class_ <B> ("B")
> .def ("getA", &B::getA, return_internal_reference <> ())
> ;
>
> It complains quite a lot, since it is an overloaded method.
Just wrap one of them; Python doesn't know/care about const.
A* (B::*getA)() = &B::getA;
class_ <B> ("B")
.def ("getA", getA, return_internal_reference <> ())
;
--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
More information about the Cplusplus-sig
mailing list