File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
src/solvers/smt2_incremental Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 10
10
#include < solvers/smt2_incremental/smt_sorts.def>
11
11
#undef SORT_ID
12
12
13
+ #define SORT_ID (the_id ) \
14
+ template <> \
15
+ const smt_##the_id##_sortt *smt_sortt::cast<smt_##the_id##_sortt>() const \
16
+ { \
17
+ return id () == ID_smt_##the_id##_sort \
18
+ ? static_cast <const smt_##the_id##_sortt *>(this ) \
19
+ : nullptr ; \
20
+ }
21
+ #include < solvers/smt2_incremental/smt_sorts.def> // NOLINT(build/include)
22
+ #undef SORT_ID
23
+
24
+ #define SORT_ID (the_id ) \
25
+ template <> \
26
+ optionalt<smt_##the_id##_sortt> smt_sortt::cast<smt_##the_id##_sortt>() && \
27
+ { \
28
+ if (id () == ID_smt_##the_id##_sort) \
29
+ return {std::move (*static_cast <const smt_##the_id##_sortt *>(this ))}; \
30
+ else \
31
+ return {}; \
32
+ }
33
+ #include < solvers/smt2_incremental/smt_sorts.def> // NOLINT(build/include)
34
+ #undef SORT_ID
35
+
13
36
bool smt_sortt::operator ==(const smt_sortt &other) const
14
37
{
15
38
return irept::operator ==(other);
Original file line number Diff line number Diff line change 8
8
#define CPROVER_SOLVERS_SMT2_INCREMENTAL_SMT_SORTS_H
9
9
10
10
#include < util/irep.h>
11
+ #include < util/optional.h>
11
12
12
13
#include < type_traits>
13
14
@@ -42,6 +43,12 @@ class smt_sortt : protected irept
42
43
static const smt_sortt &downcast (const irept &);
43
44
};
44
45
46
+ template <typename sub_classt>
47
+ const sub_classt *cast () const ;
48
+
49
+ template <typename sub_classt>
50
+ optionalt<sub_classt> cast () &&;
51
+
45
52
protected:
46
53
using irept::irept;
47
54
};
You can’t perform that action at this time.
0 commit comments