Boost logo

Boost :

From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2006-02-22 08:21:53


tal boost ha escrito:

> 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

[...]

> I will send you on a private channel some source files so maybe you
> can find out what is the problem.

I think the problem is precisely what Martin Bonner point out in his
response: you're doing

hndl_index_type & h_type = boost::multi_index::get<0>(ns);

inside a *const* method of your class (this I checked inspecting the
code you sent me privately), so that the member variable ns
is treated as const as well, and get<...>() on a const container
return const index references. So, please write

const hndl_index_type & h_type = boost::multi_index::get<0>(ns);

and try again. If this works, you might want to omit explicit
qualification and see what happens.

As for your question on how to replicate the sentence

NodePtrSet::iterator it = ns.find(theHandle);

to work for the second index, it is like this:

group_index_type::iterator it = get<1>(ns).find(theGroup);

or

const group_index_type& g_type = get<1>(ns);
group_index_type::iterator it = g_type.find(theGroup);

Please note that index #0 iterators are of a different type than
index #1 iterators. You cannot mix them, but they're sort of
translatable by means of project:

http://boost.org/libs/multi_index/doc/tutorial.html#projection

> Regards,
> Tal

Best,

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


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