make asDiscrete a template

release/4.3a0
Varun Agrawal 2025-01-01 20:34:26 -05:00
parent 62a6558d85
commit 5d2d879462
1 changed files with 4 additions and 3 deletions

View File

@ -166,12 +166,13 @@ class GTSAM_EXPORT HybridConditional
} }
/** /**
* @brief Return conditional as a DiscreteConditional * @brief Return conditional as a DiscreteConditional or specified type T.
* @return nullptr if not a DiscreteConditional * @return nullptr if not a DiscreteConditional
* @return DiscreteConditional::shared_ptr * @return DiscreteConditional::shared_ptr
*/ */
DiscreteConditional::shared_ptr asDiscrete() const { template <typename T = DiscreteConditional>
return std::dynamic_pointer_cast<DiscreteConditional>(inner_); typename T::shared_ptr asDiscrete() const {
return std::dynamic_pointer_cast<T>(inner_);
} }
/// Get the type-erased pointer to the inner type /// Get the type-erased pointer to the inner type