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