Template array constructor (#582)

This commit is contained in:
Sylvain Corlay 2017-02-14 10:55:01 +01:00 committed by Wenzel Jakob
parent a76ed42c3f
commit bee8827a98
1 changed files with 4 additions and 3 deletions

View File

@ -337,8 +337,9 @@ public:
array() : array(0, static_cast<const double *>(nullptr)) {} array() : array(0, static_cast<const double *>(nullptr)) {}
array(const pybind11::dtype &dt, const std::vector<size_t> &shape, template <typename Shape, typename Strides>
const std::vector<size_t> &strides, const void *ptr = nullptr, array(const pybind11::dtype &dt, const Shape &shape,
const Strides &strides, const void *ptr = nullptr,
handle base = handle()) { handle base = handle()) {
auto& api = detail::npy_api::get(); auto& api = detail::npy_api::get();
auto ndim = shape.size(); auto ndim = shape.size();
@ -536,7 +537,7 @@ protected:
throw std::runtime_error("array is not writeable"); throw std::runtime_error("array is not writeable");
} }
static std::vector<size_t> default_strides(const std::vector<size_t>& shape, size_t itemsize) { template <typename Shape> static std::vector<size_t> default_strides(const Shape& shape, size_t itemsize) {
auto ndim = shape.size(); auto ndim = shape.size();
std::vector<size_t> strides(ndim); std::vector<size_t> strides(ndim);
if (ndim) { if (ndim) {