Boost logo

Boost Users :

Subject: [Boost-users] [container] Initialization from transformed_range compilation error
From: Szymon Gatner (szymon.gatner_at_[hidden])
Date: 2011-09-04 06:12:41


Hi,

snipped below gives this error in VS 2008 SP1:

Error 1 error C2664: 'void
boost::container::vector<T>::priv_range_insert<InIt>(Object
**,FwdIt,FwdIt,std::forward_iterator_tag)' : cannot convert parameter
4 from 'boost::detail::iterator_category_with_traversal<Category,Traversal>'
to 'std::forward_iterator_tag' c:\devel\boost_1_47_0\boost\container\vector.hpp 1908 copy_range

code:

#include <boost/container/vector.hpp>
#include <boost/range/adaptor/transformed.hpp>
#include <functional>

class Object;

struct DecodeID : public std::unary_function<int, Object*>
{
  Object* operator() (int id) const
  {
    return 0;
  }
};

int main()
{
  using namespace boost;
  using namespace boost::container;
  using namespace boost::range;

  vector<int> ids;

  vector<Object*> objects = copy_range<vector<Object*>
>(adaptors::transform(ids, DecodeID()));
}

Am I missing something obvious here?

Regards,
Szymon

P.S. full build log:

1>------ Build started: Project: copy_range, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>c:\devel\boost_1_47_0\boost\container\vector.hpp(1908) : error
C2664: 'void boost::container::vector<T>::priv_range_insert<InIt>(Object
**,FwdIt,FwdIt,std::forward_iterator_tag)' : cannot convert parameter
4 from 'boost::detail::iterator_category_with_traversal<Category,Traversal>'
to 'std::forward_iterator_tag'
1> with
1> [
1> T=Object *,
1> InIt=boost::transform_iterator<DecodeID,boost::container::containers_detail::vector_iterator<int
*>>,
1> FwdIt=boost::transform_iterator<DecodeID,boost::container::containers_detail::vector_iterator<int
*>>
1> ]
1> and
1> [
1> Category=std::input_iterator_tag,
1> Traversal=boost::random_access_traversal_tag
1> ]
1> No user-defined-conversion operator available that can
perform this conversion, or the operator cannot be called
1> c:\devel\boost_1_47_0\boost\container\vector.hpp(1093) : see
reference to function template instantiation 'void
boost::container::vector<T>::priv_insert_dispatch<InIt>(boost::container::containers_detail::vector_const_iterator<Pointer>,InIt,InIt,boost::container::containers_detail::false_)'
being compiled
1> with
1> [
1> T=Object *,
1> InIt=boost::transform_iterator<DecodeID,boost::container::containers_detail::vector_iterator<int
*>>,
1> Pointer=Object **
1> ]
1> c:\devel\boost_1_47_0\boost\container\vector.hpp(1761) : see
reference to function template instantiation 'void
boost::container::vector<T>::insert<InIt>(boost::container::containers_detail::vector_const_iterator<Pointer>,InIt,InIt)'
being compiled
1> with
1> [
1> T=Object *,
1> InIt=boost::transform_iterator<DecodeID,boost::container::containers_detail::vector_iterator<int
*>>,
1> Pointer=Object **
1> ]
1> c:\devel\boost_1_47_0\boost\container\vector.hpp(1895) : see
reference to function template instantiation 'void
boost::container::vector<T>::priv_assign_aux<InIt>(InIt,InIt,std::input_iterator_tag)'
being compiled
1> with
1> [
1> T=Object *,
1> InIt=boost::transform_iterator<DecodeID,boost::container::containers_detail::vector_iterator<int
*>>
1> ]
1> c:\devel\boost_1_47_0\boost\container\vector.hpp(867) : see
reference to function template instantiation 'void
boost::container::vector<T>::priv_assign_dispatch<InIt>(InIt,InIt,boost::container::containers_detail::false_)'
being compiled
1> with
1> [
1> T=Object *,
1> InIt=boost::transform_iterator<DecodeID,boost::container::containers_detail::vector_iterator<int
*>>
1> ]
1> c:\devel\boost_1_47_0\boost\container\vector.hpp(487) : see
reference to function template instantiation 'void
boost::container::vector<T>::assign<InIt>(InIt,InIt)' being compiled
1> with
1> [
1> T=Object *,
1> InIt=boost::transform_iterator<DecodeID,boost::container::containers_detail::vector_iterator<int
*>>
1> ]
1> c:\devel\boost_1_47_0\boost\range\iterator_range_core.hpp(640)
: see reference to function template instantiation
'boost::container::vector<T>::vector<boost::transform_iterator<UnaryFunc,Iterator>>(InIt,InIt,const
std::allocator<_Ty> &)' being compiled
1> with
1> [
1> T=Object *,
1> UnaryFunc=DecodeID,
1> Iterator=boost::container::containers_detail::vector_iterator<int
*>,
1> InIt=boost::transform_iterator<DecodeID,boost::container::containers_detail::vector_iterator<int
*>>,
1> _Ty=Object *
1> ]
1> c:\users\bravo\documents\visual studio
2008\projects\copy_range\copy_range\main.cpp(23) : see reference to
function template instantiation 'SeqT
boost::copy_range<boost::container::vector<T>,boost::range_detail::transformed_range<F,R>>(const
Range &)' being compiled
1> with
1> [
1> SeqT=boost::container::vector<Object *>,
1> T=Object *,
1> F=DecodeID,
1> R=boost::container::vector<int>,
1> Range=boost::range_detail::transformed_range<DecodeID,boost::container::vector<int>>
1> ]
1>Build log was saved at "file://c:\Users\bravo\Documents\Visual
Studio 2008\Projects\copy_range\copy_range\Debug\BuildLog.htm"
1>copy_range - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

-- 
Szymon Gatner
The Lordz Games Studio
www.thelordzgamesstudio.com

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