Skip to content

Commit bfa326a

Browse files
authored
Make iterator_policies::sequence_fast_readonly default constructible
This makes `decltype(pybind11_tuple.begin())` satisfy the `std::input_or_output_iterator` concept, and makes `pybind11::tuple` usable as a `std::ranges::range`.
1 parent c4e2952 commit bfa326a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

include/pybind11/pytypes.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,7 @@ class sequence_fast_readonly {
882882
using reference = const handle; // PR #3263
883883
using pointer = arrow_proxy<const handle>;
884884

885+
sequence_fast_readonly() = default;
885886
sequence_fast_readonly(handle obj, ssize_t n) : ptr(PySequence_Fast_ITEMS(obj.ptr()) + n) {}
886887

887888
// NOLINTNEXTLINE(readability-const-return-type) // PR #3263
@@ -893,7 +894,7 @@ class sequence_fast_readonly {
893894
ssize_t distance_to(const sequence_fast_readonly &b) const { return ptr - b.ptr; }
894895

895896
private:
896-
PyObject **ptr;
897+
PyObject **ptr = nullptr;
897898
};
898899

899900
/// Full read and write access using the sequence protocol: see ``detail::sequence_accessor``

0 commit comments

Comments
 (0)