|
Boost Users : |
Subject: Re: [Boost-users] [ptr_container] Transferring the Last Element from a ptr_vector
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2009-09-07 03:13:14
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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net