Skip to content

Commit 5d2d879

Browse files
committed
make asDiscrete a template
1 parent 62a6558 commit 5d2d879

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

gtsam/hybrid/HybridConditional.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,13 @@ class GTSAM_EXPORT HybridConditional
166166
}
167167

168168
/**
169-
* @brief Return conditional as a DiscreteConditional
169+
* @brief Return conditional as a DiscreteConditional or specified type T.
170170
* @return nullptr if not a DiscreteConditional
171171
* @return DiscreteConditional::shared_ptr
172172
*/
173-
DiscreteConditional::shared_ptr asDiscrete() const {
174-
return std::dynamic_pointer_cast<DiscreteConditional>(inner_);
173+
template <typename T = DiscreteConditional>
174+
typename T::shared_ptr asDiscrete() const {
175+
return std::dynamic_pointer_cast<T>(inner_);
175176
}
176177

177178
/// Get the type-erased pointer to the inner type

0 commit comments

Comments
 (0)