NOLINTNEXTLINE(performance-unnecessary-value-param)
| 3389 | typename... Extra> |
| 3390 | // NOLINTNEXTLINE(performance-unnecessary-value-param) |
| 3391 | iterator make_iterator_impl(Iterator first, Sentinel last, Extra &&...extra) { |
| 3392 | using state = detail::iterator_state<Access, Policy, Iterator, Sentinel, ValueType, Extra...>; |
| 3393 | // TODO: state captures only the types of Extra, not the values |
| 3394 | |
| 3395 | // For Python < 3.14.0rc1, pycritical_section uses direct mutex locking (same as a unique |
| 3396 | // lock), which may deadlock during type registration. See detail/internals.h for details. |
| 3397 | #if PY_VERSION_HEX >= 0x030E00C1 // 3.14.0rc1 |
| 3398 | PYBIND11_LOCK_INTERNALS(get_internals()); |
| 3399 | #endif |
| 3400 | if (!detail::get_type_info(typeid(state), false)) { |
| 3401 | class_<state>(handle(), "iterator", pybind11::module_local()) |
| 3402 | .def( |
| 3403 | "__iter__", [](state &s) -> state & { return s; }, pos_only()) |
| 3404 | .def( |
| 3405 | "__next__", |
| 3406 | [](state &s) -> ValueType { |
| 3407 | if (!s.first_or_done) { |
| 3408 | ++s.it; |
| 3409 | } else { |
| 3410 | s.first_or_done = false; |
| 3411 | } |
| 3412 | if (s.it == s.end) { |
| 3413 | s.first_or_done = true; |
| 3414 | throw stop_iteration(); |
| 3415 | } |
| 3416 | return Access()(s.it); |
| 3417 | // NOLINTNEXTLINE(readability-const-return-type) // PR #3263 |
| 3418 | }, |
| 3419 | std::forward<Extra>(extra)..., |
| 3420 | pos_only(), |
| 3421 | Policy); |
| 3422 | } |
| 3423 | |
| 3424 | return cast(state{std::forward<Iterator>(first), std::forward<Sentinel>(last), true}); |
| 3425 | } |
| 3426 | |
| 3427 | PYBIND11_NAMESPACE_END(detail) |
| 3428 |
nothing calls this directly
no test coverage detected