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 1010#include < solvers/smt2_incremental/smt_sorts.def>
1111#undef SORT_ID
1212
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+
1336bool smt_sortt::operator ==(const smt_sortt &other) const
1437{
1538 return irept::operator ==(other);
Original file line number Diff line number Diff line change 88#define CPROVER_SOLVERS_SMT2_INCREMENTAL_SMT_SORTS_H
99
1010#include < util/irep.h>
11+ #include < util/optional.h>
1112
1213#include < type_traits>
1314
@@ -42,6 +43,12 @@ class smt_sortt : protected irept
4243 static const smt_sortt &downcast (const irept &);
4344 };
4445
46+ template <typename sub_classt>
47+ const sub_classt *cast () const &;
48+
49+ template <typename sub_classt>
50+ optionalt<sub_classt> cast () &&;
51+
4552protected:
4653 using irept::irept;
4754};
You can’t perform that action at this time.
0 commit comments