@@ -350,6 +350,21 @@ class TypeInfo
350350 template <typename T>
351351 static TypeInfo Create ()
352352 {
353+ // store the base class typeid if specialized
354+ if constexpr (is_shared_ptr<T>::value)
355+ {
356+ using Elem = typename T::element_type;
357+ using Base = typename any_cast_base<Elem>::type;
358+
359+ if constexpr (!std::is_same_v<Base, void >)
360+ {
361+ static_assert (std::is_polymorphic_v<Base>, " TypeInfo Base trait specialization "
362+ " must be "
363+ " polymorphic" );
364+ return TypeInfo{ typeid (std::shared_ptr<Base>),
365+ GetAnyFromStringFunctor<std::shared_ptr<Base>>() };
366+ }
367+ }
353368 return TypeInfo{ typeid (T), GetAnyFromStringFunctor<T>() };
354369 }
355370
@@ -452,7 +467,8 @@ template <typename T = AnyTypeAllowed>
452467 }
453468 else
454469 {
455- out = { sname, PortInfo (direction, typeid (T), GetAnyFromStringFunctor<T>()) };
470+ auto type_info = TypeInfo::Create<T>();
471+ out = { sname, PortInfo (direction, type_info.type (), type_info.converter ()) };
456472 }
457473 if (!description.empty ())
458474 {
@@ -501,7 +517,6 @@ BidirectionalPort(StringView name, StringView description = {})
501517
502518namespace details
503519{
504-
505520template <typename T = AnyTypeAllowed, typename DefaultT = T>
506521[[nodiscard]] inline std::pair<std::string, PortInfo>
507522PortWithDefault (PortDirection direction, StringView name, const DefaultT& default_value,
0 commit comments