Commit d2da33a3 by Jason Rhinelander

static_assert should be testing ssize_t not size_t

The numpy strides/sizes/etc. are signed now, but the static_assert
didn't get updated to match.
parent a4d0d95e
...@@ -29,10 +29,10 @@ ...@@ -29,10 +29,10 @@
#endif #endif
/* This will be true on all flat address space platforms and allows us to reduce the /* This will be true on all flat address space platforms and allows us to reduce the
whole npy_intp / size_t / Py_intptr_t business down to just size_t for all size whole npy_intp / ssize_t / Py_intptr_t business down to just ssize_t for all size
and dimension types (e.g. shape, strides, indexing), instead of inflicting this and dimension types (e.g. shape, strides, indexing), instead of inflicting this
upon the library user. */ upon the library user. */
static_assert(sizeof(size_t) == sizeof(Py_intptr_t), "size_t != Py_intptr_t"); static_assert(sizeof(ssize_t) == sizeof(Py_intptr_t), "ssize_t != Py_intptr_t");
NAMESPACE_BEGIN(pybind11) NAMESPACE_BEGIN(pybind11)
...@@ -518,8 +518,8 @@ public: ...@@ -518,8 +518,8 @@ public:
array() : array({{0}}, static_cast<const double *>(nullptr)) {} array() : array({{0}}, static_cast<const double *>(nullptr)) {}
using ShapeContainer = detail::any_container<Py_intptr_t>; using ShapeContainer = detail::any_container<ssize_t>;
using StridesContainer = detail::any_container<Py_intptr_t>; using StridesContainer = detail::any_container<ssize_t>;
// Constructs an array taking shape/strides from arbitrary container types // Constructs an array taking shape/strides from arbitrary container types
array(const pybind11::dtype &dt, ShapeContainer shape, StridesContainer strides, array(const pybind11::dtype &dt, ShapeContainer shape, StridesContainer strides,
...@@ -752,7 +752,7 @@ protected: ...@@ -752,7 +752,7 @@ protected:
throw std::domain_error("array is not writeable"); throw std::domain_error("array is not writeable");
} }
static std::vector<Py_intptr_t> default_strides(const std::vector<Py_intptr_t>& shape, ssize_t itemsize) { static std::vector<ssize_t> default_strides(const std::vector<ssize_t>& shape, ssize_t itemsize) {
auto ndim = shape.size(); auto ndim = shape.size();
std::vector<ssize_t> strides(ndim); std::vector<ssize_t> strides(ndim);
if (ndim) { if (ndim) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment