Re: [boost] multi_index with shared_ptr

----Original Message---- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of tal boost Sent: 22 February 2006 11:52 To: boost@lists.boost.org Subject: Re: [boost] multi_index with shared_ptr
Applying full qualify hndl_index_type & h_type = boost::multi_index::get<0>(ns); I get this error ////////////////////////////////// Compiling... CADDB.CPP z:\ctcadlib\include\db\caddb.cpp(258) : error C2440: 'initializing' : cannot convert from 'const class [**SNIP**]' to 'class [**SNIP**] &' Conversion loses qualifiers
The compiler believes that get<> is returning a const hdnl_index_type, and it is refusing to bind a reference to non-const to that. Of course, that simple overview does rather get lost in the template verbiage! In earlier messages you were complaining about ambiguity, so I presume this is not the root of your problem - just another manifestation of it :-(. -- Martin Bonner Martin.Bonner@Pitechnology.com Pi Technology, Milton Hall, Ely Road, Milton, Cambridge, CB4 6WZ, ENGLAND Tel: +44 (0)1223 203894

///You wrote: ...and try again. If this works, you might want to omit explicit qualification and see what happens. const hndl_index_type & h_type = get<0>(ns); Doing so, the output is again: error C2667: 'get' : none of 2 overload have a best conversion error C2668: 'get' : ambiguous call to overloaded function The following lines work fine: :)
const hndl_index_type & h_type = boost::multi_index::get<0>(ns); //works fine! boost::multi_index::get<myIndex>(ns).find(id);
I still don't get why I have to keep explicit qualification even though Its defined using namespace boost::multi_index, is defined. :(

tal boost ha escrito:
///You wrote:
...and try again. If this works, you might want to omit explicit qualification and see what happens.
const hndl_index_type & h_type = get<0>(ns);
Doing so, the output is again: error C2667: 'get' : none of 2 overload have a best conversion error C2668: 'get' : ambiguous call to overloaded function The following lines work fine: :)
const hndl_index_type & h_type = boost::multi_index::get<0>(ns); //works fine! boost::multi_index::get<myIndex>(ns).find(id);
OK, we have advanced that much, at least.
I still don't get why I have to keep explicit qualification even though Its defined using namespace boost::multi_index, is defined. :(
I've examined the sample you sent me and identified the following as the culprit: using namespace boost; using namespace boost::multi_index; Having these two using directives in effect makes the compiler get confused about get() from Boost.Tuple and get() from Boost.MultiIndex. Please note this is not your fault but the compiler's: a decent compiler has to correctly identify which get() is used in every situation. So, to get rid of the problem either qualify get() as you're doing now or omit one of the using directives. I think this completes the list of problems you've had so far, I hope your future experience is smoother --if it's not please come back. Best, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

Hi, Please note that the first index works const hndl_index_type &h_type = boost::multi_index::get<hndl>(ns); NodePtrSet::const_iterator it = h_type.find(theHandle); //works but if I try to access the 2nd index doing: ... const group_index_type &g_type = boost::multi_index::get<group>(ns); NodePtrSet::iterator group_it = g_type.find(aGroup); I get the following output error: error C2440: 'initializing' : cannot convert from 'class boost::multi_index::detail::index_iterator<struct boost::multi_index::detail::ordered_index_node<struct boost::multi_index::detail::index_node_base<class boost::shared_ptr<class CtCAD::NodeBase> > > >' to 'class boost::multi_index::detail::index_iterator<struct boost::multi_index::detail::ordered_index_node<struct boost::multi_index::detail::ordered_index_node<struct boost::multi_index::detail::index_node_base<class boost::shared_ptr<class CtCAD::NodeBase> > > > >' No constructor could take the source type, or constructor overload resolution was ambiguous Any suggestions? Regards, Tal.Agmon

tal boost ha escrito:
Hi,
Please note that the first index works const hndl_index_type &h_type = boost::multi_index::get<hndl>(ns); NodePtrSet::const_iterator it = h_type.find(theHandle); //works
but if I try to access the 2nd index doing: ... const group_index_type &g_type = boost::multi_index::get<group>(ns); NodePtrSet::iterator group_it = g_type.find(aGroup);
I get the following output error:
[...] Replace NodePtrSet::iterator group_it = ...; with group_index_type::iterator it = ...; NodePtrSet::iterator (which is the same as hndl_index_type::iterator since hndl_index_type is index #0) is a different type than group_index_type::iterator, which is associated to index #1. You cannot freely mix iterators from different indices, though if the necessity arises you can convert between them with project() capabilities: http://boost.org/libs/multi_index/doc/tutorial.html#projection HTH, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
participants (3)
-
Joaquín Mª López Muñoz
-
Martin Bonner
-
tal boost