mirror of
https://github.com/pybind/pybind11.git
synced 2026-04-19 22:39:09 +00:00
Convenience constructor templates for buffer_info (#860)
* Added template constructors to buffer_info that can deduce the item size, format string, and number of dimensions from the pointer type and the shape container * Implemented actual buffer_info constructor as private delegate constructor taking rvalue reference as a workaround for the evaluation order move problem on GCC 4.8
This commit is contained in:
committed by
Dean Moldovan
parent
427e4afc69
commit
b700c5d672
@@ -136,9 +136,6 @@ test_initializer buffers([](py::module &m) {
|
||||
.def_buffer([](Matrix &m) -> py::buffer_info {
|
||||
return py::buffer_info(
|
||||
m.data(), /* Pointer to buffer */
|
||||
sizeof(float), /* Size of one scalar */
|
||||
py::format_descriptor<float>::format(), /* Python struct-style format descriptor */
|
||||
2, /* Number of dimensions */
|
||||
{ m.rows(), m.cols() }, /* Buffer dimensions */
|
||||
{ sizeof(float) * size_t(m.rows()), /* Strides (in bytes) for each index */
|
||||
sizeof(float) }
|
||||
|
||||
Reference in New Issue
Block a user