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

Function potentially_slicing_weak_ptr

include/pybind11/cast.h:1159–1168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1157/// completing the cycle
1158template <typename T>
1159std::weak_ptr<T> potentially_slicing_weak_ptr(handle obj) {
1160 detail::make_caster<std::shared_ptr<T>> caster;
1161 if (caster.load(obj, /*convert=*/true)) {
1162 return caster.potentially_slicing_weak_ptr();
1163 }
1164 const char *obj_type_name = detail::obj_class_name(obj.ptr());
1165 throw type_error("\"" + std::string(obj_type_name)
1166 + "\" object is not convertible to std::weak_ptr<T> (with T = " + type_id<T>()
1167 + ")");
1168}
1169
1170PYBIND11_NAMESPACE_BEGIN(detail)
1171

Callers

nothing calls this directly

Calls 4

obj_class_nameFunction · 0.85
ptrMethod · 0.80
loadMethod · 0.45

Tested by

no test coverage detected