【发布时间】:2017-04-01 15:13:51
【问题描述】:
我在使用 Z3::expr 作为地图值类型时遇到了困难。编译器抱怨不能使用默认构造函数。一个玩具示例如下所示。
#include <z3++.h>
#include <map>
//#include <vector>
using namespace std;
using namespace z3;
int main() {
map <int, expr> m;
context c;
m[1] = c.bool_const("x");
return 0;
}
编译器(Clang++)抱怨
no matching constructor for initialization of 'mapped_type' (aka 'z3::expr')
__i = insert(__i, value_type(__k, mapped_type()));
in instantiation of member function 'std::map<int, z3::expr, std::less<int>,
std::allocator<std::pair<const int, z3::expr> > >::operator[]' requested here
m[1] = c.bool_const("x");
/usr/include/z3++.h:562:9: note: candidate constructor not viable: requires single argument 'c', but no arguments were provided
expr(context & c):ast(c) {}
^
/usr/include/z3++.h:564:9: note: candidate constructor not viable: requires single argument 'n', but no arguments were provided
expr(expr const & n):ast(n) {}
^
/usr/include/z3++.h:563:9: note: candidate constructor not viable: requires 2 arguments, but 0 were provided
expr(context & c, Z3_ast n):ast(c, reinterpret_cast<Z3_ast>(n)) {}
使用向量将 expr 或 find 方法包装在 map 中作为替代方法似乎很好。有没有办法直接用expr作为map值类型+[]操作符?
【问题讨论】:
标签: z3