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);
}
This function should take the last element from each container and transfer
it to the beginning of the other container. The unswapGene function will not
compile. Here's the compiler message.
C:\Boost SVN\trunk\boost/range/const_iterator.hpp(37) : error C2039:
'const_iterator' : is not a member of 'boost::reverse_iterator<Iterator>'
with [Iterator=boost::void_ptr_iterator>,genprg::Gene>]
C:\Boost SVN\trunk\boost/mpl/eval_if.hpp(63) : see reference to class
template instantiation 'boost::range_const_iterator<C>' being compiled
with
[C=boost::reverse_iterator>,genprg::Gene>>]
C:\Boost SVN\trunk\boost/range/iterator.hpp(63) : see reference to class
template instantiation 'boost::mpl::eval_if_c' being compiled
with [C=true,
F1=boost::range_const_iterator>,genprg::Gene>>>,
F2=boost::range_mutable_iterator>,genprg::Gene>>>]
C:\Boost SVN\trunk\boost/ptr_container/ptr_sequence_adapter.hpp(458) :
see reference to class template instantiation 'boost::range_iterator<C>'
being compiled
with [C=const
boost::reverse_iterator>,genprg::Gene>>]
..\..\..\..\GSSTA\gene.cpp(560) : see reference to function template
instantiation 'void
boost::ptr_sequence_adapter::transfer(boost::void_ptr_iterator,const
Range &,PtrSeqAdapter &)' being compiled
with [T=genprg::Gene, VoidPtrSeq=std::vector>, CloneAllocator=boost::heap_clone_allocator,
Iterator=boost::void_ptr_iterator>,genprg::Gene>, VoidIter=std::_Vector_iterator>,
Range=boost::reverse_iterator>,genprg::Gene>>,
PtrSeqAdapter=genprg::Gene::GeneVectType]
Can anyone see what I'm doing wrong?
--
Charles