27
27
// / \tparam T The exprt-derived class to check for
28
28
// / \param base Reference to a generic \ref exprt
29
29
// / \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);
31
31
32
32
// / Called after casting. Provides a point to assert on the structure of the
33
33
// / 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
45
45
{
46
46
static_assert (
47
47
!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 &>" );
49
50
50
51
typedef
51
52
typename std::conditional<
@@ -78,7 +79,7 @@ auto expr_try_dynamic_cast(TExpr &base)
78
79
static_assert (
79
80
std::is_base_of<exprt, T>::value,
80
81
" 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))
82
83
return nullptr ;
83
84
const auto ret=static_cast <returnt>(&base);
84
85
validate_expr (*ret);
@@ -93,7 +94,8 @@ struct expr_dynamic_cast_return_typet final
93
94
{
94
95
static_assert (
95
96
!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 &>" );
97
99
98
100
typedef
99
101
typename std::conditional<
0 commit comments