我解决了“呼叫没有匹配功能”的问题。
现在我得到这个我根本不明白的错误。
/usr/include/c++/4.3/bits/stl_iterator.h: In member function 'std::front_insert_iterator<_Container>& std::front_insert_iterator<_Container>::operator=(typename _Container::const_reference) [with _Container = std::vector<int, std::allocator<int> >]':
/usr/include/c++/4.3/bits/stl_algobase.h:342: instantiated from 'static _OI std::__copy_move<false, false, std::random_access_iterator_tag>::__copy_m(_II, _II, _OI) [with _II = int*, _OI = std::front_insert_iterator<std::vector<int, std::allocator<int> > >]'
/usr/include/c++/4.3/bits/stl_algobase.h:396: instantiated from '_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false, _II = int*, _OI = std::front_insert_iterator<std::vector<int, std::allocator<int> > >]'
/usr/include/c++/4.3/bits/stl_algobase.h:435: instantiated from '_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false, _II = __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, _OI = std::front_insert_iterator<std::vector<int, std::allocator<int> > >]'
/usr/include/c++/4.3/bits/stl_algobase.h:466: instantiated from '_OI std::copy(_II, _II, _OI) [with _II = __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, _OI = std::front_insert_iterator<std::vector<int, std::allocator<int> > >]'
我的新代码是:
vector<int> PI_comb(vector<int> Tree, vector<int> legs, int pi){
vector<int> rooted(NG-1);
for(int i=0;i<NG-1;i++)rooted.at(i)=Tree.at(i);
vector< vector<int> > L;
L.resize(legs.size());
for(int azz=0;azz<legs.size();azz++)L[azz].resize(legs.at(azz));
for(int rho=0;rho<legs.size();rho++){
for(int i=0;i<legs[rho];i++)L[rho][i]=rooted.at(i);
}
vector< vector<int> > newTree/*(std::pow(2,NG-3),vector<int>(NG-1))*/;
for(int cc=0;cc<legs.size();cc++){
if(legs.at(cc)==2){
vector<int> ROW(legs.at(cc));
for(int argh=0;argh<legs.at(cc);argh++)ROW.at(argh)=L[cc][argh];
vector<int> REVROW(ROW.rbegin(), ROW.rend());
for(int i2=0;i2<(std::pow(2,NG-4)-1);i2++){
if (i2%2==0)
{
if (i2==0||i2==4||i2==8)
std::copy(ROW.begin(),ROW.end(),std::back_inserter<vector<int> >(newTree.at(i2)));
else
std::copy(REVROW.begin(),REVROW.end(),std::back_inserter<vector<int> >(newTree.at(i2)));
}
else
{
if (i2==1||i2==5||i2==9)
/*LINE 156*/std::copy(ROW.begin(),ROW.end(),std::front_inserter<vector<int> >(newTree.at(i2)));
else
std::copy(REVROW.begin(),REVROW.end(),std::front_inserter<vector<int> >(newTree.at(i2)));
}
}
for(int i2=std::pow(2,NG-4);i2<(std::pow(2,NG-3)-1);i2+=2){
if(cc>0&&legs.at(cc-1)==2){
if (i2%2==0)
{
if (i2==0||i2==4||i2==8)
std::copy(REVROW.begin(),REVROW.end(),std::back_inserter<vector<int> >(newTree.at(i2)));
else
std::copy(ROW.begin(),ROW.end(),std::back_inserter<vector<int> >(newTree.at(i2)));
}
else
{
if (i2==1||i2==5||i2==9)
std::copy(REVROW.begin(),REVROW.end(),std::front_inserter<vector<int> >(newTree.at(i2)));
else
std::copy(ROW.begin(),ROW.end(),std::front_inserter<vector<int> >(newTree.at(i2)));
}
}
else{
if (i2%2==0)
{
if (i2==0||i2==4||i2==8)
std::copy(ROW.begin(),ROW.end(),std::back_inserter<vector<int> >(newTree.at(i2)));
else
std::copy(REVROW.begin(),REVROW.end(),std::back_inserter<vector<int> >(newTree.at(i2)));
}
else
{
if (i2==1||i2==5||i2==9)
std::copy(ROW.begin(),ROW.end(),std::front_inserter<vector<int> >(newTree.at(i2)));
else
std::copy(REVROW.begin(),REVROW.end(),std::front_inserter<vector<int> >(newTree.at(i2)));
}
}
}
}
else if(legs.at(cc)==1){
vector<int> ROW(legs.at(cc));
for(int argh=0;argh<legs.at(cc);argh++)ROW.at(argh)=L[cc][argh];
if(cc!=legs.size()-1){
for(int i2=0;i2<(std::pow(2,NG-3)-1);i2+=2){
if (i2%2==0)
{
std::copy(ROW.begin(),ROW.end(),std::back_inserter<vector<int> >(newTree.at(i2)));
}
else
{
std::copy(ROW.begin(),ROW.end(),std::front_inserter<vector<int> >(newTree.at(i2)));
}
}
}
else if(cc==legs.size()-1){
for(int i2=0;i2<std::pow(2,NG-3);i2++)newTree.push_back(ROW);
}
}
}
//RETURN
if(pi<=std::pow(2,NG-3)){
for(int ag=0;ag<NG-1;ag++)
Tree.at(ag)=newTree[pi][ag];
}
else if(pi>std::pow(2,NG-3)){
vector<int> row(NG-1);
for(int a=0;a<NG-1;a++)row.at(a)=newTree[pi-std::pow(2,NG-3)][a];
vector<int> REVrow(row.rbegin(), row.rend());
for(int a=0;a<NG-1;a++)Tree.at(a)=REVrow.at(a);
}
return(Tree);
}
这只是一个根据一些特殊模式基本上改变向量树内元素顺序的函数。我认为现在它会做我想做的事..但我不明白这些错误。
好的,我解决了。vector 没有定义 front_inserter。
我不得不使用:
copy(ROW.begin(),ROW.end(),inserter(newTree[i2],newTree[i2].begin()));