問題描述
最近在使用PBC庫寫關於雙線性對的代碼時,恰巧想用向量vector來存儲元素element_t變量,但是卻碰見了意外。
首先我聲明瞭一個element_t的向量。
std::vector<element_t> tau;
然而,當我想要push_back()
時
for(int i=0;i<blockNum;i++){
in_tau>>buff;
element_t tem_tau;
element_init_Zr(tem_tau, pairing);
element_set_str(tem_tau, buff, 16);
tau.push_back(tem_tau);
}
報錯了,錯誤很長這裏就不貼了。
未解決
由於擺渡了半天也沒發現答案,並且這個庫比較小衆,所以就去外邊找了找,在stack overflow上找到了類似的問題。下邊的回答是這樣寫的
“I think the problem is that PBC is a C lobrary and element_t is missing the required copy constructor for vector to work with it. Note that there is a C++ wrapper for PBC avaliable.”
注意,PBC庫是有C++封裝版本的。