Skip to content

Commit 8189692

Browse files
committed
Template array constructor
1 parent 2723a38 commit 8189692

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

include/pybind11/numpy.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,9 @@ class array : public buffer {
328328

329329
array() : array(0, static_cast<const double *>(nullptr)) {}
330330

331-
array(const pybind11::dtype &dt, const std::vector<size_t> &shape,
332-
const std::vector<size_t> &strides, const void *ptr = nullptr,
331+
template <typename Shape, typename Strides>
332+
array(const pybind11::dtype &dt, const Shape &shape,
333+
const Strides &strides, const void *ptr = nullptr,
333334
handle base = handle()) {
334335
auto& api = detail::npy_api::get();
335336
auto ndim = shape.size();
@@ -525,7 +526,7 @@ class array : public buffer {
525526
throw std::runtime_error("array is not writeable");
526527
}
527528

528-
static std::vector<size_t> default_strides(const std::vector<size_t>& shape, size_t itemsize) {
529+
template <typename Shape> static std::vector<size_t> default_strides(const Shape& shape, size_t itemsize) {
529530
auto ndim = shape.size();
530531
std::vector<size_t> strides(ndim);
531532
if (ndim) {

0 commit comments

Comments
 (0)