13
13
#include " expr.h"
14
14
15
15
16
- // / \brief Check whether a reference to a generic \ref exprt is of a specific derived class
16
+ // / \brief Check whether a reference to a generic \ref exprt is of a specific
17
+ // / derived class.
18
+ // /
17
19
// / Implement template specializations of this function to enable casting
20
+ // /
18
21
// / \tparam T The exprt-derived class to check for
19
22
// / \param base Reference to a generic \ref exprt
20
23
// / \return true if \a base is of type \a T
21
24
template <typename T> bool check_expr_type (const exprt &base);
22
25
23
- // / \brief Check whether a reference to a generic \ref exprt is of a specific derived class
24
- // / Implement template specializations of this function to enable casting
25
- // / \tparam T The exprt-derived class to check for
26
- // / \param base Reference to a generic \ref exprt
27
- // / \return true if \a base is of type \a T
28
- template <typename T> void validate_expr (const T &value) { }
29
-
30
26
template <typename T> struct remove_constt ;
31
27
template <typename T> struct remove_constt <const T> { using type=T; };
32
28
template <typename T> struct ptr_typet ;
@@ -35,10 +31,12 @@ template<typename T> struct ref_typet;
35
31
template <typename T> struct ref_typet <T &> { using type=T; };
36
32
37
33
38
- // / \brief Cast a constant pointer to a generic exprt to a specific derived class
34
+ // / \brief Cast a constant pointer to a generic exprt to a specific derived
35
+ // / class
39
36
// / \tparam T The exprt-derived class to cast to
40
37
// / \param base Pointer to a generic \ref exprt
41
- // / \return Pointer to object of type \a T or null if \a base is not an instance of \a T
38
+ // / \return Pointer to object of type \a T or null if \a base is not an
39
+ // / instance of \a T
42
40
template <typename T>
43
41
T expr_dynamic_cast (const exprt *base)
44
42
{
@@ -51,7 +49,8 @@ T expr_dynamic_cast(const exprt *base)
51
49
// / \brief Cast a pointer to a generic exprt to a specific derived class
52
50
// / \tparam T The exprt-derived class to cast to
53
51
// / \param base Pointer to a generic \ref exprt
54
- // / \return Pointer to object of type \a T or null if \a base is not an instance of \a T
52
+ // / \return Pointer to object of type \a T or null if \a base is not an
53
+ // / instance of \a T
55
54
template <typename T>
56
55
T expr_dynamic_cast (exprt *base)
57
56
{
@@ -75,11 +74,12 @@ T expr_dynamic_cast(TExpr *base)
75
74
if (!check_expr_type<TUnderlying>(*base))
76
75
return nullptr ;
77
76
T value=static_cast <T>(base);
78
- validate_expr<TUnderlying> (*value);
77
+ validate_expr (*value);
79
78
return value;
80
79
}
81
80
82
- // / \brief Cast a constant reference to a generic exprt to a specific derived class
81
+ // / \brief Cast a constant reference to a generic exprt to a specific derived
82
+ // / class
83
83
// / \tparam T The exprt-derived class to cast to
84
84
// / \param base Reference to a generic \ref exprt
85
85
// / \return Reference to object of type \a T
@@ -119,7 +119,7 @@ T expr_dynamic_cast(TExpr &base)
119
119
if (!check_expr_type<TUnderlying>(base))
120
120
throw std::bad_cast ();
121
121
T value=static_cast <T>(base);
122
- validate_expr<TUnderlying> (value);
122
+ validate_expr (value);
123
123
return value;
124
124
}
125
125
0 commit comments