boost python: tie lifetime of argument to returned value using return_internal_reference
问题 I begin learning to use boost python and have a rookie question. I would like to write a function that can tie the lifetime of its argument to its results, such that when I call r = func(a) , the argument a will never be destroyed if I still have a reference of r . The documentation suggests using return_internal_reference call policy for this type of request. But does this require r to be an internal reference of a , as the name suggested? In the (over-simplified) example below, suppose I