std::array<> caster: support arbitrary sequences (#1602)
This PR brings the std::array<> caster in sync with the other STL type
casters: to accept an arbitrary sequence as input (rather than a list,
which is too restrictive).
diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp
index 8736ea8..0bb6433 100644
--- a/tests/test_stl.cpp
+++ b/tests/test_stl.cpp
@@ -263,4 +263,6 @@
return result;
},
py::return_value_policy::take_ownership);
+
+ m.def("array_cast_sequence", [](std::array<int, 3> x) { return x; });
}
diff --git a/tests/test_stl.py b/tests/test_stl.py
index b78f86a..9e58223 100644
--- a/tests/test_stl.py
+++ b/tests/test_stl.py
@@ -216,3 +216,7 @@
assert len(r) == 1
del r
assert cstats.alive() == 0
+
+
+def test_array_cast_sequence():
+ assert m.array_cast_sequence((1, 2, 3)) == [1, 2, 3]