Skip to content

Commit

Permalink
Add Size to lambda capture
Browse files Browse the repository at this point in the history
  • Loading branch information
musshorn authored and wjakob committed Aug 25, 2020
1 parent 07a8424 commit 3e36c87
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions python/vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ auto register_vector_type(py::module &m, const char *name) {

array.def(py::init<Value>())
.def(py::init<const Array &>())
.def(py::init([](const std::array<Value, Size> &arr) {
.def(py::init([Size](const std::array<Value, Size> &arr) {
Array a;
for (size_t i = 0; i < Size; ++i)
a[i] = arr[i];
Expand All @@ -37,12 +37,12 @@ auto register_vector_type(py::module &m, const char *name) {
.def(py::self -= py::self)
.def(py::self *= py::self)
.def(py::self /= py::self)
.def("__getitem__", [](const Array &a, size_t index) -> Value {
.def("__getitem__", [Size](const Array &a, size_t index) -> Value {
if (index >= Size)
throw py::index_error();
return a[index];
}, "index"_a)
.def("__setitem__", [](Array &a, size_t index, Value value) {
.def("__setitem__", [Size](Array &a, size_t index, Value value) {
if (index >= Size)
throw py::index_error();
a[index] = value;
Expand All @@ -51,7 +51,7 @@ auto register_vector_type(py::module &m, const char *name) {
[](Array &a, const Value &v) { a.x() = v; })
.def_property("y", [](const Array &a) { return a.y(); },
[](Array &a, const Value &v) { a.y() = v; })
.def_buffer([](Array &m) -> py::buffer_info {
.def_buffer([Size](Array &m) -> py::buffer_info {
return py::buffer_info(
m.v, // Pointer to buffer
sizeof(Value), // Size of one scalar
Expand Down

0 comments on commit 3e36c87

Please sign in to comment.