Boost logo

Boost Users :

From: Charles Brockman (cmbrockman_at_[hidden])
Date: 2008-02-17 19:29:48


Is it possible to use Boost ptr_containers with Boost zip iterators?

I switched from std::map to boost::ptr_map in my application and received
numerous complaints from the Microsoft Visual Studio C++ 2008 compiler. As
a small test I compiled \trunk\libs\iterator\test\zip_iterator_test.cpp from
Boost SVN which worked fine. Then I added the necessary ptr_container
include file, disabled a lot of extra tests and changed the definition of
the two vectors from
std::vector<double> vect1(3); to boost::ptr_vector<double> vect1(3); and
std::vector<double> vect2(3); to boost::ptr_vector<double> vect2(3);

Here is the error reported:
c:\boost svn\trunk\boost\tuple\detail\tuple_basic.hpp(373) : error C2664:
'std::_Vector_const_iterator<_Ty,_Alloc>::_Vector_const_iterator(const
std::_Vector_const_iterator<_Ty,_Alloc> &)' : cannot convert parameter 1
from 'const boost::void_ptr_iterator<VoidIter,T>' to 'const
std::_Vector_const_iterator<_Ty,_Alloc> &'
        with [ _Ty=double, _Alloc=std::allocator<double> ]
        and [ VoidIter=std::_Vector_iterator<void *,std::allocator<void *>>,
T=double ]
        and [ _Ty=double, _Alloc=std::allocator<double> ]
        Reason: cannot convert from 'const
boost::void_ptr_iterator<VoidIter,T>' to 'const
std::_Vector_const_iterator<_Ty,_Alloc>'
        with [ VoidIter=std::_Vector_iterator<void *,std::allocator<void
*>>, T=double ]
        and [ _Ty=double, _Alloc=std::allocator<double> ]
        No user-defined-conversion operator available that can perform this
conversion, or the operator cannot be called
        c:\boost svn\trunk\boost\tuple\detail\tuple_basic.hpp(626) : see
reference to function template instantiation
'boost::tuples::cons<HT,TT>::cons<T0,boost::tuples::cons<T0,boost::tuples::detail::map_tuple_to_cons<boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>::type>>(const
boost::tuples::cons<T0,boost::tuples::cons<T0,boost::tuples::detail::map_tuple_to_cons<boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>::type>>
&)' being compiled with
[HT=std::_Vector_const_iterator<double,std::allocator<double>>,TT=boost::tuples::cons<std::_Vector_const_iterator<double,std::allocator<double>>,boost::tuples::detail::map_tuple_to_cons<boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>::type>,
            T0=boost::void_ptr_iterator<std::_Vector_iterator<void
*,std::allocator<void *>>,double> ]
        c:\documents and settings\chuck\my documents\visual studio
2005\projects\zip ptr container test\zip_ptr_container_test.cpp(267) : see
reference to function template instantiation
'boost::tuples::tuple<T0,T1>::tuple<boost::void_ptr_iterator<VoidIter,T>,boost::tuples::cons<HT,TT>>(const
boost::tuples::cons<HT,boost::tuples::cons<HT,TT>> &)' being compiled
        with [
T0=std::_Vector_const_iterator<double,std::allocator<double>>,
            T1=std::_Vector_const_iterator<double,std::allocator<double>>,
            VoidIter=std::_Vector_iterator<void *,std::allocator<void *>>,
            T=double,
            HT=boost::void_ptr_iterator<std::_Vector_iterator<void
*,std::allocator<void *>>,double>,
TT=boost::tuples::detail::map_tuple_to_cons<boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type,boost::tuples::null_type>::type
 ]

The line 267 (line 295 in the original version) referred to is:
boost::zip_iterator< boost::tuples::tuple<
std::vector<double>::const_iterator, std::vector<double>::const_iterator >
> zip_it_begin( boost::make_tuple( vect1.begin(), vect2.begin() ) );

Is it the void pointer in the ptr_vector which causes the problem?

Can this marriage be saved?

-- 
Chuck

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