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

Method add_base

include/pybind11/pybind11.h:2394–2405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2392
2393 template <typename Base, detail::enable_if_t<is_base<Base>::value, int> = 0>
2394 static void add_base(detail::type_record &rec) {
2395 rec.add_base(typeid(Base), [](void *src) -> void * {
2396 return static_cast<Base *>(reinterpret_cast<type *>(src));
2397 });
2398 // Virtual inheritance means the base subobject is at a dynamic offset,
2399 // so the reinterpret_cast shortcut in load_impl Case 2a is invalid.
2400 // Force the MI path (implicit_casts) for correct pointer adjustment.
2401 // Detection: static_cast<Derived*>(Base*) is ill-formed for virtual bases.
2402 if PYBIND11_MAYBE_CONSTEXPR (!detail::is_static_downcastable<Base, type>::value) {
2403 rec.multiple_inheritance = true;
2404 }
2405 }
2406
2407 template <typename Base, detail::enable_if_t<!is_base<Base>::value, int> = 0>
2408 static void add_base(detail::type_record &) {}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected