2727// / \tparam T The exprt-derived class to check for
2828// / \param base Reference to a generic \ref exprt
2929// / \return true if \a base is of type \a T
30- template <typename T> bool can_cast_expr (const exprt &base);
30+ template <typename T> inline bool can_cast_expr (const exprt &base);
3131
3232// / Called after casting. Provides a point to assert on the structure of the
3333// / expr. By default, this is a no-op, but you can provide an overload to
@@ -45,7 +45,8 @@ struct expr_try_dynamic_cast_return_typet final
4545{
4646 static_assert (
4747 !std::is_reference<Ret>::value,
48- " Ret must be non-qualified" );
48+ " Ret must not be a reference, i.e. expr_try_dynamic_cast<const thingt> "
49+ " rather than expr_try_dynamic_cast<const thing &>" );
4950
5051 typedef
5152 typename std::conditional<
@@ -78,7 +79,7 @@ auto expr_try_dynamic_cast(TExpr &base)
7879 static_assert (
7980 std::is_base_of<exprt, T>::value,
8081 " The template argument T must be derived from exprt." );
81- if (!can_cast_expr<T >(base))
82+ if (!can_cast_expr<typename std::remove_const<T>::type >(base))
8283 return nullptr ;
8384 const auto ret=static_cast <returnt>(&base);
8485 validate_expr (*ret);
@@ -93,7 +94,8 @@ struct expr_dynamic_cast_return_typet final
9394{
9495 static_assert (
9596 !std::is_reference<Ret>::value,
96- " Ret must be non-qualified" );
97+ " Ret must not be a reference, i.e. expr_dynamic_cast<const thingt> rather "
98+ " than expr_dynamic_cast<const thing &>" );
9799
98100 typedef
99101 typename std::conditional<
0 commit comments