On Jul 18, 2014 6:32 AM, "Kv Gopalkrishnan" <kvgopalkrishn...@gmail.com>
wrote:
>
> Hi Jim
>           Thank you for the answer. When I tried this solution
> i.e.  .def("GetHeading",&GetHeading)
> error: ‘GetHeading’ was not declared in this scope
>
>
> I get the above error.
> Stating the obvious the error  says function was not described in the
scope. Seems a bit nasty business is it so that I would have to write a get
function in someway in to public domain to get the function wrapped in to
boost?
>

I'm pretty sure that should have worked.  Could you post a more complete
example?  I suspect the problem is elsewhere.

Jim

>
> On Thu, Jul 17, 2014 at 3:12 PM, Jim Bosch <tallji...@gmail.com> wrote:
>>
>> The problem here is actually a  C++ issue, not a Boost.Python one.
 Friend functions aren't considered to be part of the scope of the class
that they're friends with, so when referring to them, just use e.g.
"&GetHeading", not "&Turtle::GetHeading".
>>
>> Jim
>>
>>
>> On Wed, Jul 16, 2014 at 7:52 AM, Kv Gopalkrishnan <
kvgopalkrishn...@gmail.com> wrote:
>>>
>>> I want to expose a C++ friend functions to python using Python boost.
>>>   class Turtle{
>>>                    friend const PV& GetHeading(const Turtle& t);
>>>                    friend const PV& GetLeft(const Turtle& t);
>>>                    friend const P& GetPoint(const Turtle& t);
>>>                    friend void SetPoint(Turtle& t, const P& p);
>>>                    public:
>>>
>>>                    ...
>>>
>>>                    private:
>>>                    PV h;
>>>                    PV l;
>>>
>>>               };
>>>
>>>
>>> Here I have wrapped the classes PV and P so no problem there. I tried
to wrap the friend functions like regular functions. Like
>>>
>>>               BOOST_PYTHON_MODULE(TurtleWrapper)
>>>                   {
>>>                      class_<Turtle>("Turtle")
>>>                        .def("GetHeading",&Turtle::GetHeading)
>>>                        .def("GetLeft",&Turtle::GetLeft)
>>>                        .add_property("h",&Turtle::GetHeading)
>>>                        .add_property("l",&Turtle::GetLeft);
>>>                  }
>>> When i run the code i get error messages.
>>>
>>>                error: ‘GetHeading’ is not a member of ‘Turtle’
>>>                error: ‘GetLeft’ is not a member of ‘Turtle’
>>>
>>> This error is seen for add_property and also .def.
>>> So I assume that this is not the way to declare a friend function and
the documentation of python boost does not seem (or at least I did not see
a note about friend functions). Any help is much appreciated.
>>>
>>>
>>>
>>> Kind Regards
>>> K.V.
>>>
>>> _______________________________________________
>>> Cplusplus-sig mailing list
>>> Cplusplus-sig@python.org
>>> https://mail.python.org/mailman/listinfo/cplusplus-sig
>>
>>
>>
>> _______________________________________________
>> Cplusplus-sig mailing list
>> Cplusplus-sig@python.org
>> https://mail.python.org/mailman/listinfo/cplusplus-sig
>
>
>
>
> --
> K.V.
>
> _______________________________________________
> Cplusplus-sig mailing list
> Cplusplus-sig@python.org
> https://mail.python.org/mailman/listinfo/cplusplus-sig
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
https://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to