Boost logo

Boost Users :

From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2007-09-19 06:28:13


Hi Paul,

Paul.VanHagen_at_[hidden] ha escrito:

> Hello,
>
> I am having trouble using a boost::multi_index_container type in a template class where the
> multi-index value type is depending on the template arg type of the class.
>
> In particular, I'm getting compiler errors when trying to define the iterator and index types
> using the "type" typedefs in the multi_index container. Apparently, at compile time the
> index and iterator types cannot be deduced resulting in errors like "cannot convert to
> typename, etc.".
>
> I'm using GCC 3.3.1 and Boost 1.34.1.

Well, seems like the compiler is having a hard time with dependent nested types.
Probably newer versions of GCC will pose less problems. Fortunately, you can
use global variants for nth_index etc., which happen to be easier for the compiler.
So, instead of

  typedef typename mi::nth_index<0>::type mi_by_value;

you can write

  typedef typename nth_index<mi,0>::type mi_by_value;

Besides, you write in several places:

  m_c.get<...>()

but as the calls are in dependent contexts you have to write them like this instead:

  m_c.template get<...>()

or like this, as you're alreading doing in MultiIndex::MultiIndex():

  get<...>(m_c)

The attached code includes all the corrections above and have been verified
to compile and run OK with GCC 3.2. Hope this helps,

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




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