RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
boost_shared_ptr.h File Reference
#include <nanobind/nanobind.h>
#include <boost/shared_ptr.hpp>

Go to the source code of this file.

Classes

struct  boost_py_deleter
 
struct  type_caster< boost::shared_ptr< T > >
 

Functions

template<typename T>
NB_NOINLINE boost::shared_ptr< T > boost_shared_from_python (T *ptr, handle h) noexcept
 
NB_NOINLINE void boost_shared_from_cpp (boost::shared_ptr< void > &&ptr, PyObject *o) noexcept
 

Function Documentation

◆ boost_shared_from_cpp()

NB_NOINLINE void boost_shared_from_cpp ( boost::shared_ptr< void > && ptr,
PyObject * o )
inlinenoexcept

Definition at line 55 of file boost_shared_ptr.h.

Referenced by type_caster< boost::shared_ptr< T > >::from_cpp().

◆ boost_shared_from_python()

template<typename T>
NB_NOINLINE boost::shared_ptr< T > boost_shared_from_python ( T * ptr,
handle h )
inlinenoexcept

Create a std::shared_ptr for ptr that owns a reference to the Python object h; if ptr is non-null, then the refcount of h is incremented before creating the shared_ptr and decremented by its deleter.

Usually this is instantiated with T = void, to reduce template bloat. But if the pointee type uses enable_shared_from_this, we instantiate with T = that type, in order to allow its internal weak_ptr to share ownership with the shared_ptr we're creating.

The next two functions are simultaneously marked as 'inline' (to avoid linker errors) and 'NB_NOINLINE' (to avoid them being inlined into every single shared_ptr type_caster, which would enlarge the binding size)

Definition at line 47 of file boost_shared_ptr.h.

Referenced by type_caster< boost::shared_ptr< T > >::from_python().