MCPcopy Create free account
hub / github.com/pybind/pybind11 / cast

Method cast

include/pybind11/stl.h:456–468  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

454
455 template <typename T>
456 static handle cast(T &&src, return_value_policy policy, handle parent) {
457 list l(src.size());
458 ssize_t index = 0;
459 for (auto &&value : src) {
460 auto value_ = reinterpret_steal<object>(
461 value_conv::cast(detail::forward_like<T>(value), policy, parent));
462 if (!value_) {
463 return handle();
464 }
465 PyList_SET_ITEM(l.ptr(), index++, value_.release().ptr()); // steals a reference
466 }
467 return l.release();
468 }
469
470 // Code copied from PYBIND11_TYPE_CASTER macro.
471 // Intentionally preserving the behavior exactly as it was before PR #5305

Callers

nothing calls this directly

Calls 7

noneClass · 0.85
moveFunction · 0.85
ptrMethod · 0.80
releaseMethod · 0.80
castFunction · 0.70
handleFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected