Follow the link in Boost :: Python

Consider something like:

struct Parameter
{
    int a;
    Parameter(){a = 0;}
    void setA(int newA){a = newA;}
};
struct MyClass
{
    void changeParameter(Parameter &p){ p.setA(-1);}
};

Ok, let's go ahead and imagine that I have already wrapped these classes, exposing everything in python, and imagine that I am creating an instance of a Parameter object in C ++ code, which I pass to a python script, and that the python script uses the MyClass object to modify an instance of parameter I created at the beginning of C ++ code.

After executing this code, in C ++ the instance parameter has not changed !!! This means that it was passed by value (or something similar: S), and not by reference. But I thought I announced that it was passed by reference ...

I can not find the Boost :: Python documentation on passing by reference (although there seems to be enough document on returning by reference ...). Can someone give any hint or pointer please?

+3
1

Python , , python boost::python copy-ctor .

: ( ) python / " ".

+1

Source: https://habr.com/ru/post/1737270/


All Articles