我试图对NTL-Library中定义的任意长度整数向量使用std::set,但由于某种原因,它不起作用。它可以很好地处理由库定义的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;
}有没有人知道为什么第一个插入可以,第二个不能?
发布于 2012-01-27 22:05:05
std::set<T>按std::less<T>排序,默认为bool operator<(T,T)。ZZ确实定义了一个合适的operator< (它们是有序的),但vec_ZZ没有,事实上,大多数NTL类没有,甚至ZZ_p也没有。因此,std::set<ZZ_p>同样是无效的。
https://stackoverflow.com/questions/9032470
复制相似问题