Boost logo

Boost :

Subject: Re: [boost] How to use mutable_queue with non basic types
From: Emili Hernàndez (emilihb_at_[hidden])
Date: 2010-04-12 07:00:12


Jeremiah Willcock escribió:
> On Fri, 9 Apr 2010, Emili Hernàndez wrote:
>
>> Hi all,
>>
>> I've used mutable_queue with basic types (double and int) with no
>> problem.
>> Now I trying to do it with my own type:
>>
>> typedef MyObject entry_t;
>> typedef vector<entry_t> storage_t;
>> typedef MySortingCriterion comp_t;
>> typedef boost::identity_property_map prop_map_t;
>> typedef boost::mutable_queue<entry_t, storage_t, comp_t, prop_map_t>
>> queue_t;
>
> identity_property_map is only for unsigned ints (it's that way for
> historical reasons). Use typed_identity_property_map<entry_t> as
> prop_map_t and see if that fixes your problem.
>
> -- Jeremiah Willcock
>
Hi,
I've tried what you suggested and another error apperars:

C:\boost\boost_1_42_0/boost/pending/mutable_queue.hpp: In member
function 'void boost::mutable_queue<IndexedType, RandomAccessContainer,
Comp, ID>::push(const IndexedType&) [with IndexedType =
boost::shared_ptr<CAStarNode>, RandomAccessContainer =
std::vector<boost::shared_ptr<CAStarNode>,
std::allocator<boost::shared_ptr<CAStarNode> > >, Comp =
astarnode::SGreater, ID =
boost::typed_identity_property_map<boost::shared_ptr<CAStarNode> >]':
..\CAStar.cpp:76: instantiated from here
C:\boost\boost_1_42_0/boost/pending/mutable_queue.hpp:94: error: no
match for 'operator[]' in
'((boost::mutable_queue<boost::shared_ptr<CAStarNode>,
std::vector<boost::shared_ptr<CAStarNode>,
std::allocator<boost::shared_ptr<CAStarNode> > >, astarnode::SGreater,
boost::typed_identity_property_map<boost::shared_ptr<CAStarNode> >
>*)this)->boost::mutable_queue<boost::shared_ptr<CAStarNode>,
std::vector<boost::shared_ptr<CAStarNode>,
std::allocator<boost::shared_ptr<CAStarNode> > >, astarnode::SGreater,
boost::typed_identity_property_map<boost::shared_ptr<CAStarNode> >
>::index_array[boost::get(const boost::put_get_helper<Reference,
PropertyMap>&, const K&) [with PropertyMap =
boost::typed_identity_property_map<boost::shared_ptr<CAStarNode> >,
Reference = boost::shared_ptr<CAStarNode>, K =
boost::shared_ptr<CAStarNode>](((const
boost::shared_ptr<CAStarNode>&)((const boost::shared_ptr<CAStarNode>*)x)))]'
c:\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/stl_vector.h:610:
note: candidates are: typename std::_Vector_base<_Tp,
_Alloc>::_Tp_alloc_type::reference std::vector<_Tp,
_Alloc>::operator[](size_t) [with _Tp = unsigned int, _Alloc =
std::allocator<unsigned int>]
c:\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/stl_vector.h:625:
note: typename std::_Vector_base<_Tp,
_Alloc>::_Tp_alloc_type::const_reference std::vector<_Tp,
_Alloc>::operator[](size_t) const [with _Tp = unsigned int, _Alloc =
std::allocator<unsigned int>]
In file included from
C:\boost\boost_1_42_0/boost/pending/mutable_queue.hpp:20,
                 from ..\/CAStar.h:90,
                 from ..\CAStar.cpp:8:
C:\boost\boost_1_42_0/boost/graph/detail/array_binary_tree.hpp: In
member function 'void
adstl::array_binary_tree_node<RandomAccessIterator,
ID>::swap(adstl::array_binary_tree_node<RandomAccessIterator, ID>,
ExternalData&) [with ExternalData = std::vector<unsigned int,
std::allocator<unsigned int> >, RandomAccessIterator =
__gnu_cxx::__normal_iterator<boost::shared_ptr<CAStarNode>*,
std::vector<boost::shared_ptr<CAStarNode>,
std::allocator<boost::shared_ptr<CAStarNode> > > >, ID =
boost::typed_identity_property_map<boost::shared_ptr<CAStarNode> >]':
C:\boost\boost_1_42_0/boost/pending/mutable_heap.hpp:38: instantiated
from 'TreeNode boost::up_heap(TreeNode, const Compare&, ExternalData&)
[with TreeNode =
adstl::array_binary_tree_node<__gnu_cxx::__normal_iterator<boost::shared_ptr<CAStarNode>*,
std::vector<boost::shared_ptr<CAStarNode>,
std::allocator<boost::shared_ptr<CAStarNode> > > >,
boost::typed_identity_property_map<boost::shared_ptr<CAStarNode> > >,
Compare =
adstl::compare_array_node<std::vector<boost::shared_ptr<CAStarNode>,
std::allocator<boost::shared_ptr<CAStarNode> > >, astarnode::SGreater>,
ExternalData = std::vector<unsigned int, std::allocator<unsigned int> >]'
C:\boost\boost_1_42_0/boost/pending/mutable_queue.hpp:96: instantiated
from 'void boost::mutable_queue<IndexedType, RandomAccessContainer,
Comp, ID>::push(const IndexedType&) [with IndexedType =
boost::shared_ptr<CAStarNode>, RandomAccessContainer =
std::vector<boost::shared_ptr<CAStarNode>,
std::allocator<boost::shared_ptr<CAStarNode> > >, Comp =
astarnode::SGreater, ID =
boost::typed_identity_property_map<boost::shared_ptr<CAStarNode> >]'
..\CAStar.cpp:76: instantiated from here
C:\boost\boost_1_42_0/boost/graph/detail/array_binary_tree.hpp:143:
error: no match for 'operator[]' in 'edata[boost::get(const
boost::put_get_helper<Reference, PropertyMap>&, const K&) [with
PropertyMap =
boost::typed_identity_property_map<boost::shared_ptr<CAStarNode> >,
Reference = boost::shared_ptr<CAStarNode>, K =
boost::shared_ptr<CAStarNode>](((const
boost::shared_ptr<CAStarNode>&)((const boost::shared_ptr<CAStarNode>*)(&
tmp))))]'
c:\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/stl_vector.h:610:
note: candidates are: typename std::_Vector_base<_Tp,
_Alloc>::_Tp_alloc_type::reference std::vector<_Tp,
_Alloc>::operator[](size_t) [with _Tp = unsigned int, _Alloc =
std::allocator<unsigned int>]
c:\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/stl_vector.h:625:
note: typename std::_Vector_base<_Tp,
_Alloc>::_Tp_alloc_type::const_reference std::vector<_Tp,
_Alloc>::operator[](size_t) const [with _Tp = unsigned int, _Alloc =
std::allocator<unsigned int>]
C:\boost\boost_1_42_0/boost/graph/detail/array_binary_tree.hpp:144:
error: no match for 'operator[]' in 'edata[boost::get(const
boost::put_get_helper<Reference, PropertyMap>&, const K&) [with
PropertyMap =
boost::typed_identity_property_map<boost::shared_ptr<CAStarNode> >,
Reference = boost::shared_ptr<CAStarNode>, K =
boost::shared_ptr<CAStarNode>](((const
boost::shared_ptr<CAStarNode>&)((const
boost::shared_ptr<CAStarNode>*)adstl::array_binary_tree_node<RandomAccessIterator,
ID>::value [with RandomAccessIterator =
__gnu_cxx::__normal_iterator<boost::shared_ptr<CAStarNode>*,
std::vector<boost::shared_ptr<CAStarNode>,
std::allocator<boost::shared_ptr<CAStarNode> > > >, ID =
boost::typed_identity_property_map<boost::shared_ptr<CAStarNode> >]())))]'
c:\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/stl_vector.h:610:
note: candidates are: typename std::_Vector_base<_Tp,
_Alloc>::_Tp_alloc_type::reference std::vector<_Tp,
_Alloc>::operator[](size_t) [with _Tp = unsigned int, _Alloc =
std::allocator<unsigned int>]
c:\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/stl_vector.h:625:
note: typename std::_Vector_base<_Tp,
_Alloc>::_Tp_alloc_type::const_reference std::vector<_Tp,
_Alloc>::operator[](size_t) const [with _Tp = unsigned int, _Alloc =
std::allocator<unsigned int>]

it seams that the operator[] has to be defined but I don't understand
why is it required if it is already specified to use a vector<entry_t>
as storage type

Any suggestion?
Is there a full example on how to use mutable_queue with non-basic types??

Thanks

Emili
> ------------------------------------------------------------------------
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk