25 bool readonly =
false;
27 buffer_info() =
default;
30 detail::any_container<ssize_t> shape_in, detail::any_container<ssize_t> strides_in,
bool readonly=
false)
31 : ptr(ptr), itemsize(itemsize), size(1), format(format), ndim(ndim),
32 shape(
std::
move(shape_in)), strides(
std::
move(strides_in)), readonly(readonly) {
33 if (ndim != (
ssize_t) shape.size() || ndim != (
ssize_t) strides.size())
34 pybind11_fail(
"buffer_info: ndim doesn't match shape and/or strides length");
35 for (
size_t i = 0;
i < (
size_t) ndim; ++
i)
40 buffer_info(
T *ptr, detail::any_container<ssize_t> shape_in, detail::any_container<ssize_t> strides_in,
bool readonly=
false)
44 : buffer_info(ptr, itemsize, format, 1, {size}, {itemsize}, readonly) { }
52 : buffer_info(const_cast<
T*>(ptr), sizeof(
T),
format_descriptor<
T>::format(), size, readonly) { }
55 : buffer_info(view->buf, view->itemsize, view->format, view->ndim,
56 {view->shape, view->shape + view->ndim}, {
view->strides,
view->strides +
view->ndim},
view->readonly) {
58 this->ownview = ownview;
61 buffer_info(
const buffer_info &) =
delete;
62 buffer_info& operator=(
const buffer_info &) =
delete;
65 (*this) = std::move(other);
70 itemsize = rhs.itemsize;
72 format = std::move(rhs.format);
74 shape = std::move(rhs.shape);
75 strides = std::move(rhs.strides);
78 readonly = rhs.readonly;
83 if (m_view && ownview) { PyBuffer_Release(m_view);
delete m_view; }
86 Py_buffer *
view()
const {
return m_view; }
87 Py_buffer *&
view() {
return m_view; }
92 detail::any_container<ssize_t> &&shape_in, detail::any_container<ssize_t> &&strides_in,
bool readonly)
93 : buffer_info(ptr, itemsize, format, ndim,
std::
move(shape_in),
std::
move(strides_in), readonly) { }
95 Py_buffer *m_view =
nullptr;
std::vector< ssize_t > strides
static bool compare(const buffer_info &b)
buffer_info(private_ctr_tag, void *ptr, ssize_t itemsize, const std::string &format, ssize_t ndim, detail::any_container< ssize_t > &&shape_in, detail::any_container< ssize_t > &&strides_in, bool readonly)
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set view
#define PYBIND11_NAMESPACE
buffer_info(buffer_info &&other)
PyExc_RuntimeError[[noreturn]] PYBIND11_NOINLINE void pybind11_fail(const char *reason)
Used internally.
detail::enable_if_t<!detail::move_never< T >::value, T > move(object &&obj)
buffer_info & operator=(buffer_info &&rhs)
static bool compare(const buffer_info &b)
buffer_info(T *ptr, detail::any_container< ssize_t > shape_in, detail::any_container< ssize_t > strides_in, bool readonly=false)
Eigen::Triplet< double > T
buffer_info(Py_buffer *view, bool ownview=true)
std::vector< ssize_t > shape
buffer_info(const T *ptr, ssize_t size, bool readonly=true)
buffer_info(T *ptr, ssize_t size, bool readonly=false)
typename std::enable_if< B, T >::type enable_if_t
from cpp_future import (convenient aliases from C++14/17)
Information record describing a Python buffer object.
buffer_info(void *ptr, ssize_t itemsize, const std::string &format, ssize_t size, bool readonly=false)
buffer_info(void *ptr, ssize_t itemsize, const std::string &format, ssize_t ndim, detail::any_container< ssize_t > shape_in, detail::any_container< ssize_t > strides_in, bool readonly=false)
void swap(mpfr::mpreal &x, mpfr::mpreal &y)
#define PYBIND11_NAMESPACE_END(name)
#define PYBIND11_NAMESPACE_BEGIN(name)