#include <pytypes.h>
Public Member Functions | |
template<typename T > | |
T | cast () const |
template<> | |
void | cast () const |
bool | check () const |
const handle & | dec_ref () const & |
handle ()=default | |
The default constructor creates a handle with a nullptr -valued pointer. More... | |
template<typename T , detail::enable_if_t< detail::all_of< detail::none_of< std::is_base_of< handle, T >, detail::is_pyobj_ptr_or_nullptr_t< T >>, std::is_convertible< T, PyObject * >>::value, int > = 0> | |
handle (T &obj) | |
Enable implicit conversion through T::operator PyObject *() . More... | |
template<typename T , detail::enable_if_t< detail::is_pyobj_ptr_or_nullptr_t< T >::value, int > = 0> | |
handle (T ptr) | |
const handle & | inc_ref () const & |
operator bool () const | |
Return true when the handle wraps a valid Python object. More... | |
bool | operator!= (const handle &h) const |
bool | operator== (const handle &h) const |
PyObject *& | ptr () |
PyObject * | ptr () const |
Return the underlying PyObject * pointer. More... | |
Static Public Member Functions | |
static std::size_t | inc_ref_counter () |
Protected Attributes | |
PyObject * | m_ptr = nullptr |
Private Member Functions | |
void | throw_gilstate_error (const std::string &function_name) const |
Static Private Member Functions | |
static std::size_t | inc_ref_counter (std::size_t add) |
\rst Holds a reference to a Python object (no reference counting)
The handle
class is a thin wrapper around an arbitrary Python object (i.e. a PyObject *
in Python's C API). It does not perform any automatic reference counting and merely provides a basic C++ interface to various Python API functions.
.. seealso:: The object
class inherits from handle
and adds automatic reference counting features. \endrst
|
default |
The default constructor creates a handle with a nullptr
-valued pointer.
|
inline |
Enable implicit conversion from PyObject *
and nullptr
. Not using handle(PyObject *ptr)
to avoid implicit conversion from 0
.
|
inline |
T handle::cast |
|
inline |
|
inline |
|
inlinestatic |
|
inlinestaticprivate |
|
inlineexplicit |
|
inline |
|
inline |
|
inline |
|
inlineprivate |