3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-28 08:58:44 +00:00

make unit types generic

This commit is contained in:
Nikolaj Bjorner 2021-05-20 15:28:26 -07:00
parent 8a5addd891
commit 7a1a2b2525
2 changed files with 10 additions and 7 deletions

View file

@ -254,11 +254,12 @@ namespace polysat {
}; };
struct uint64_ext { template<typename uint_type>
typedef uint64_t numeral; struct generic_uint_ext {
typedef uint_type numeral;
struct manager { struct manager {
typedef uint64_t numeral; typedef uint_type numeral;
struct hash { struct hash {
unsigned operator()(numeral const& n) const { unsigned operator()(numeral const& n) const {
return static_cast<unsigned>(n); return static_cast<unsigned>(n);
@ -269,7 +270,7 @@ namespace polysat {
return a == b; return a == b;
} }
}; };
numeral from_rational(rational const& n) { return n.get_uint64(); } numeral from_rational(rational const& n) { return static_cast<uint_type>(n.get_uint64()); }
void reset() {} void reset() {}
void reset(numeral& n) { n = 0; } void reset(numeral& n) { n = 0; }
void del(numeral const& n) {} void del(numeral const& n) {}
@ -333,6 +334,8 @@ namespace polysat {
typedef _scoped_numeral<manager> scoped_numeral; typedef _scoped_numeral<manager> scoped_numeral;
}; };
typedef generic_uint_ext<uint64_t> uint64_ext;
template<typename Ext> template<typename Ext>
inline std::ostream& operator<<(std::ostream& out, fixplex<Ext> const& fp) { inline std::ostream& operator<<(std::ostream& out, fixplex<Ext> const& fp) {

View file

@ -64,12 +64,12 @@ namespace polysat {
fixplex_base* b = m_fix.get(sz, nullptr); fixplex_base* b = m_fix.get(sz, nullptr);
if (!b) { if (!b) {
switch (sz) { switch (sz) {
case 32:
b = alloc(fixplex<generic_uint_ext<unsigned>>, s.m_lim);
break;
case 64: case 64:
b = alloc(fixplex<uint64_ext>, s.m_lim); b = alloc(fixplex<uint64_ext>, s.m_lim);
break; break;
case 8:
case 16:
case 32:
case 128: case 128:
case 256: case 256:
default: default: