@@ -29,10 +29,45 @@ class smt_termt : protected irept, private smt_sortt::storert<smt_termt>
29
29
void accept (smt_term_const_downcast_visitort &) const ;
30
30
void accept (smt_term_const_downcast_visitort &&) const ;
31
31
32
+ // / \brief Class for adding the ability to up and down cast smt_termt to and
33
+ // / from irept. These casts are required by other irept derived classes in
34
+ // / order to store instances of smt_termt inside them.
35
+ // / \tparam derivedt The type of class which derives from this class and from
36
+ // / irept.
37
+ template <typename derivedt>
38
+ class storert
39
+ {
40
+ protected:
41
+ storert ();
42
+ static irept upcast (smt_termt term);
43
+ static const smt_termt &downcast (const irept &);
44
+ };
45
+
32
46
protected:
33
47
smt_termt (irep_idt id, smt_sortt sort);
34
48
};
35
49
50
+ template <typename derivedt>
51
+ smt_termt::storert<derivedt>::storert()
52
+ {
53
+ static_assert (
54
+ std::is_base_of<irept, derivedt>::value &&
55
+ std::is_base_of<storert<derivedt>, derivedt>::value,
56
+ " Only irept based classes need to upcast smt_termt to store it." );
57
+ }
58
+
59
+ template <typename derivedt>
60
+ irept smt_termt::storert<derivedt>::upcast(smt_termt term)
61
+ {
62
+ return static_cast <irept &&>(std::move (term));
63
+ }
64
+
65
+ template <typename derivedt>
66
+ const smt_termt &smt_termt::storert<derivedt>::downcast(const irept &irep)
67
+ {
68
+ return static_cast <const smt_termt &>(irep);
69
+ }
70
+
36
71
class smt_bool_literal_termt : public smt_termt
37
72
{
38
73
public:
0 commit comments