简体   繁体   中英

How does Boost.Python hold C++ class?

I know how to use Boost.Python to wrap a C++ class exposing to Python. It's really powerful for using Boost.Python to do wrapping things so conveniently.

However, few details is explained about how does Boost.Python hold a C++ class.

The code of Boost.Python is hard to read or debug, for it's written in a template meta programming fashion and all things just execute during compile time. I've scaned the documentation and "Building Hybrid Systems With Boost Python" article by the authors, yet didn't find the answer.

So, how does Boost.Python hold C++ class?

Does it hold the wrapped C++ class instance as a private member of PyObject ? Are all the inheritance, polymorphic etc. features of a wrapped class mimicked by delegating to the held instance?

So, how does Boost.Python hold C++ class?

To be pedantic, in C++ there are no classes at run-time, only objects or instances of a class.

Boost class wrappers hold your C++ objects either by value or via a smart pointer (currently only deprecated std::auto_ptr is supported).

Unfortunately boost.python documentation is rather lacking, here are some useful links for you:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM