Loading...
Searching...
No Matches
util.h
Go to the documentation of this file.
1// BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE
2
3#ifndef AWKWARDPY_UTIL_H_
4#define AWKWARDPY_UTIL_H_
5
6#include <pybind11/pybind11.h>
7#include <pybind11/numpy.h>
8
25template<typename T>
27public:
29 pyobject_deleter(PyObject *pyobj): pyobj_(pyobj) {
30 Py_INCREF(pyobj_);
31 }
34 void operator()(T const * /* p */) {
35 Py_DECREF(pyobj_);
36 }
37private:
39 PyObject* pyobj_;
40};
41
42#endif // AWKWARDPY_UTIL_H_
Used as a std::shared_ptr deleter (second argument) to overload delete ptr with Py_DECREF(ptr).
Definition util.h:26
void operator()(T const *)
Called by std::shared_ptr when its reference count reaches zero.
Definition util.h:34
pyobject_deleter(PyObject *pyobj)
Creates a pyobject_deleter and calls Py_INCREF(ptr).
Definition util.h:29