Skip to content

Commit e485f36

Browse files
committed
interop with boost::intrusive_ptr
1 parent 4a328d6 commit e485f36

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

include/boost/openmethod/interop/boost_intrusive_ptr.hpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ struct virtual_traits<boost::intrusive_ptr<Class>, Registry> {
4848
using element_type = typename OverriderType::element_type;
4949

5050
if constexpr (detail::requires_dynamic_cast<Class*, element_type*>) {
51-
return boost::dynamic_pointer_cast<element_type>(obj);
51+
// make it work with custom RTTI
52+
return OverriderType(
53+
&Registry::rtti::template dynamic_cast_ref<element_type&>(
54+
*obj));
5255
} else {
5356
return boost::static_pointer_cast<element_type>(obj);
5457
}
@@ -98,7 +101,11 @@ struct virtual_traits<const boost::intrusive_ptr<Class>&, Registry> {
98101

99102
if constexpr (detail::requires_dynamic_cast<
100103
Class*, element_type*>) {
101-
return boost::dynamic_pointer_cast<element_type>(obj);
104+
// make it work with custom RTTI
105+
return std::remove_const_t<
106+
std::remove_reference_t<OverriderType>>(
107+
&Registry::rtti::template dynamic_cast_ref<element_type&>(
108+
*obj));
102109
} else {
103110
return boost::static_pointer_cast<element_type>(obj);
104111
}

0 commit comments

Comments
 (0)