boost-python

boost python: tie lifetime of argument to returned value using return_internal_reference

前提是你 提交于 2021-02-07 09:17:10
问题 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

boost python: tie lifetime of argument to returned value using return_internal_reference

只愿长相守 提交于 2021-02-07 09:16:23
问题 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

C++ Boost.Python : 2 problems

半城伤御伤魂 提交于 2021-02-07 07:08:32
问题 So, i search good tool to integrate my C++ code with python, and at first i looked at boost.python. I've get hello examle from boost documentation and try to build and run it. Source code is (src/hello.cpp): #include <Python.h> #include <boost/python.hpp> char const* greet() { return "hello, world"; } BOOST_PYTHON_MODULE(hello_ext) { using namespace boost::python; def("greet", greet); } Problem 1 - Windows and mingw I try to build and my result : g++ -o build\hello.o -c -IE:\Programming\libs

C++ Boost.Python : 2 problems

落爺英雄遲暮 提交于 2021-02-07 07:07:16
问题 So, i search good tool to integrate my C++ code with python, and at first i looked at boost.python. I've get hello examle from boost documentation and try to build and run it. Source code is (src/hello.cpp): #include <Python.h> #include <boost/python.hpp> char const* greet() { return "hello, world"; } BOOST_PYTHON_MODULE(hello_ext) { using namespace boost::python; def("greet", greet); } Problem 1 - Windows and mingw I try to build and my result : g++ -o build\hello.o -c -IE:\Programming\libs

C++ Boost.Python : 2 problems

我的未来我决定 提交于 2021-02-07 07:07:03
问题 So, i search good tool to integrate my C++ code with python, and at first i looked at boost.python. I've get hello examle from boost documentation and try to build and run it. Source code is (src/hello.cpp): #include <Python.h> #include <boost/python.hpp> char const* greet() { return "hello, world"; } BOOST_PYTHON_MODULE(hello_ext) { using namespace boost::python; def("greet", greet); } Problem 1 - Windows and mingw I try to build and my result : g++ -o build\hello.o -c -IE:\Programming\libs