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

Method init_holder

include/pybind11/pybind11.h:2713–2729  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2711 /// Initialize holder object, variant 1: object derives from enable_shared_from_this
2712 template <typename T>
2713 static void init_holder(detail::instance *inst,
2714 detail::value_and_holder &v_h,
2715 const holder_type * /* unused */,
2716 const std::enable_shared_from_this<T> * /* dummy */) {
2717
2718 auto sh = std::dynamic_pointer_cast<typename holder_type::element_type>(
2719 detail::try_get_shared_from_this(v_h.value_ptr<type>()));
2720 if (sh) {
2721 new (std::addressof(v_h.holder<holder_type>())) holder_type(std::move(sh));
2722 v_h.set_holder_constructed();
2723 }
2724
2725 if (!v_h.holder_constructed() && inst->owned) {
2726 new (std::addressof(v_h.holder<holder_type>())) holder_type(v_h.value_ptr<type>());
2727 v_h.set_holder_constructed();
2728 }
2729 }
2730
2731 static void init_holder_from_existing(const detail::value_and_holder &v_h,
2732 const holder_type *holder_ptr,

Callers

nothing calls this directly

Calls 4

try_get_shared_from_thisFunction · 0.85
moveFunction · 0.85
holder_constructedMethod · 0.80

Tested by

no test coverage detected