문제
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;
}
.
첫 번째 삽입이 작동하는 이유와 두 번째가 아닌 이유는 무엇입니까?
해결책
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