summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorAndres Noetzli <andres.noetzli@gmail.com>2018-07-15 04:25:57 -0700
committerAina Niemetz <aina.niemetz@gmail.com>2018-07-15 04:25:57 -0700
commitd4c49e755a53e7333c7638a5aeafe8baa2ea56d3 (patch)
treed5e31f1b318cf85ed511c37f9afc5ab836700386 /src/util
parent292b2c5712ce31282ac3ec564f268ee7f0aa3506 (diff)
Avoid ambiguous overloads in BitVector (#2169)
`long` is a 32-bit integer on Windows. CVC4's BitVector class had a constructor for `unsigned int` and `unsigned long`, which lead to issues with the new CVC4 C++ API because the two constructors were ambiguous overloads. This commit changes the constructors to use `uint32_t` and `uint64_t`, which are plattform independent and more explicit (mirroring
Diffstat (limited to 'src/util')
-rw-r--r--src/util/bitvector.h19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/util/bitvector.h b/src/util/bitvector.h
index fbd1c60b7..13c1f14dd 100644
--- a/src/util/bitvector.h
+++ b/src/util/bitvector.h
@@ -19,6 +19,7 @@
#ifndef __CVC4__BITVECTOR_H
#define __CVC4__BITVECTOR_H
+#include <cstdint>
#include <iosfwd>
#include "base/exception.h"
@@ -36,12 +37,26 @@ class CVC4_PUBLIC BitVector
BitVector(unsigned size = 0) : d_size(size), d_value(0) {}
- BitVector(unsigned size, unsigned int z) : d_size(size), d_value(z)
+ /**
+ * BitVector constructor using a 32-bit unsigned integer for the value.
+ *
+ * Note: we use an explicit bit-width here to be consistent across
+ * platforms (long is 32-bit when compiling 64-bit binaries on
+ * Windows but 64-bit on Linux) and to prevent ambiguous overloads.
+ */
+ BitVector(unsigned size, uint32_t z) : d_size(size), d_value(z)
{
d_value = d_value.modByPow2(size);
}
- BitVector(unsigned size, unsigned long int z) : d_size(size), d_value(z)
+ /**
+ * BitVector constructor using a 64-bit unsigned integer for the value.
+ *
+ * Note: we use an explicit bit-width here to be consistent across
+ * platforms (long is 32-bit when compiling 64-bit binaries on
+ * Windows but 64-bit on Linux) and to prevent ambiguous overloads.
+ */
+ BitVector(unsigned size, uint64_t z) : d_size(size), d_value(z)
{
d_value = d_value.modByPow2(size);
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback