
Charles Brockman skrev:
I have two functions which swap elements between ptr_vectors. The first compiles and apparently works correctly.
typedef boost::ptr_vector<Gene> GeneVectType; GeneVectType geneVect;
void Gene::swapGene(Gene* other) { geneVect.transfer(geneVect.end(), other->geneVect.begin(), other->geneVect); other->geneVect.transfer(other->geneVect.end(), geneVect.begin(), geneVect); }
Occasionally I must reverse the swap with this unswap function.
void Gene::unswapGene(Gene* other) { // The line below is line 560 referred to in the error message. geneVect.transfer(geneVect.begin(), other->geneVect.rbegin(), other->geneVect); other->geneVect.transfer(other->geneVect.begin(), geneVect.rbegin(), geneVect); }
You can't use reverse iterators in transfer. HTH -Thorsten