Boost.python automatically convert parameter

后端 未结 2 1989
离开以前
离开以前 2021-01-20 17:16

I am using boost.python to wrap a C++ class \'A\' which takes a string as constructor. I then have a function \'fun(A& arg)\' which takes a reference to an \'A\' as para

2条回答
  •  借酒劲吻你
    2021-01-20 17:59

    For that to work fun(a) would have to modify the original a object reference. What fun(a) actually gets is a local copy of object reference a, not the original a object reference passed as an argument.

    In other words, Python does not work like that, you would need to call it as a = fun(a) to be able to change reference a (not the object it refers to).

提交回复
热议问题