@@ -110,6 +110,18 @@ class type_with_subtypet:public typet
110
110
#endif
111
111
};
112
112
113
+ inline const type_with_subtypet &to_type_with_subtype (const typet &type)
114
+ {
115
+ PRECONDITION (type.has_subtype ());
116
+ return static_cast <const type_with_subtypet &>(type);
117
+ }
118
+
119
+ inline type_with_subtypet &to_type_with_subtype (typet &type)
120
+ {
121
+ PRECONDITION (type.has_subtype ());
122
+ return static_cast <type_with_subtypet &>(type);
123
+ }
124
+
113
125
// / Type with multiple subtypes.
114
126
class type_with_subtypest :public typet
115
127
{
@@ -133,15 +145,25 @@ class type_with_subtypest:public typet
133
145
#endif
134
146
};
135
147
148
+ inline const type_with_subtypest &to_type_with_subtypes (const typet &type)
149
+ {
150
+ return static_cast <const type_with_subtypest &>(type);
151
+ }
152
+
153
+ inline type_with_subtypest &to_type_with_subtypes (typet &type)
154
+ {
155
+ return static_cast <type_with_subtypest &>(type);
156
+ }
157
+
136
158
#define forall_subtypes (it, type ) \
137
159
if ((type).has_subtypes()) /* NOLINT(readability/braces) */ \
138
- for (typet ::subtypest::const_iterator it=(type).subtypes().begin(), \
139
- it##_end=(type).subtypes().end(); \
160
+ for (type_with_subtypest ::subtypest::const_iterator it=to_type_with_subtypes (type).subtypes().begin(), \
161
+ it##_end=to_type_with_subtypes (type).subtypes().end(); \
140
162
it!=it##_end; ++it)
141
163
142
164
#define Forall_subtypes (it, type ) \
143
165
if ((type).has_subtypes()) /* NOLINT(readability/braces) */ \
144
- for (typet ::subtypest::iterator it=(type).subtypes().begin(); \
145
- it!=(type).subtypes().end(); ++it)
166
+ for (type_with_subtypest ::subtypest::iterator it=to_type_with_subtypes (type).subtypes().begin(); \
167
+ it!=to_type_with_subtypes (type).subtypes().end(); ++it)
146
168
147
169
#endif // CPROVER_UTIL_TYPE_H
0 commit comments