Skip to content

Commit 8e92a66

Browse files
author
thk123
committed
Adding can_cast_type for arary_typet
Unify using the same check in case more strict checks were introduced
1 parent 3a9ca83 commit 8e92a66

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/util/std_types.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,12 @@ class array_typet:public type_with_subtypet
10321032
}
10331033
};
10341034

1035+
template <>
1036+
inline bool can_cast_type<array_typet>(const typet &type)
1037+
{
1038+
return type.id() == ID_array;
1039+
}
1040+
10351041
/*! \brief Cast a generic typet to an \ref array_typet
10361042
*
10371043
* This is an unchecked conversion. \a type must be known to be \ref
@@ -1044,7 +1050,7 @@ class array_typet:public type_with_subtypet
10441050
*/
10451051
inline const array_typet &to_array_type(const typet &type)
10461052
{
1047-
PRECONDITION(type.id()==ID_array);
1053+
PRECONDITION(can_cast_type<array_typet>(type));
10481054
return static_cast<const array_typet &>(type);
10491055
}
10501056

@@ -1053,7 +1059,7 @@ inline const array_typet &to_array_type(const typet &type)
10531059
*/
10541060
inline array_typet &to_array_type(typet &type)
10551061
{
1056-
PRECONDITION(type.id()==ID_array);
1062+
PRECONDITION(can_cast_type<array_typet>(type));
10571063
return static_cast<array_typet &>(type);
10581064
}
10591065

0 commit comments

Comments
 (0)