题
我正在尝试使用std ::设置从ntl-library定义的任意长度的整数矢量,并且出于某种原因它不起作用。它与库定义的ZZ整数完全很好:
#include <NTL/ZZ.h>
#include <NTL/vec_ZZ.h>
#include <set>
NTL_CLIENT
int main(void){
std::set<ZZ> foo;
foo.insert(to_ZZ(1)); //works without problems
std::set<vec_ZZ> vectorFoo;
vec_ZZ vec;
vectorFoo.insert(vec); //causes compiler to crash
return 0;
}
.
有谁知道为什么第一个插入工作和第二个没有?
解决方案
std::set<T>
is ordered by std::less<T>
, which defaults to bool operator<(T,T)
. ZZ
does define a proper operator<
(they're ordered) but vec_ZZ
doesn't. In fact, most NTL classes don't, not even ZZ_p
. Therefore std::set<ZZ_p>
is equally invalid.
不隶属于 StackOverflow