// literals are represented as the negation of the index.
d_nextVarIdx(1),
d_statistics(registry, name)
+{
+}
+
+void CadicalSolver::init()
{
d_true = newVar();
d_false = newVar();
class CadicalSolver : public SatSolver
{
- public:
- CadicalSolver(StatisticsRegistry* registry, const std::string& name = "");
+ friend class SatSolverFactory;
+ public:
~CadicalSolver() override;
ClauseId addClause(SatClause& clause, bool removable) override;
bool ok() const override;
private:
+ /**
+ * Private to disallow creation outside of SatSolverFactory.
+ * Function init() must be called after creation.
+ */
+ CadicalSolver(StatisticsRegistry* registry, const std::string& name = "");
+ /**
+ * Initialize SAT solver instance.
+ * Note: Split out to not call virtual functions in constructor.
+ */
+ void init();
+
std::unique_ptr<CaDiCaL::Solver> d_solver;
unsigned d_nextVarIdx;
const std::string& name)
{
#ifdef CVC4_USE_CADICAL
- return new CadicalSolver(registry, name);
+ CadicalSolver* res = new CadicalSolver(registry, name);
+ res->init();
+ return res;
#else
Unreachable() << "CVC4 was not compiled with CaDiCaL support.";
#endif