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

Method cast_impl

include/pybind11/cast.h:826–845  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

824 /* Implementation: Convert a C++ tuple into a Python tuple */
825 template <typename T, size_t... Is>
826 static handle
827 cast_impl(T &&src, return_value_policy policy, handle parent, index_sequence<Is...>) {
828 PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(src, policy, parent);
829 PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(policy, parent);
830
831 std::array<object, size> entries{{reinterpret_steal<object>(
832 // NOLINTNEXTLINE(bugprone-use-after-move)
833 make_caster<Ts>::cast(std::get<Is>(std::forward<T>(src)), policy, parent))...}};
834 for (const auto &entry : entries) {
835 if (!entry) {
836 return handle();
837 }
838 }
839 tuple result(size);
840 int counter = 0;
841 for (auto &entry : entries) {
842 PyTuple_SET_ITEM(result.ptr(), counter++, entry.release().ptr());
843 }
844 return result.release();
845 }
846
847 Tuple<make_caster<Ts>...> subcasters;
848};

Callers

nothing calls this directly

Calls 4

ptrMethod · 0.80
releaseMethod · 0.80
castFunction · 0.70
handleFunction · 0.70

Tested by

no test coverage detected