Boost logo

Boost Users :

From: Paul.VanHagen_at_[hidden]
Date: 2007-09-19 10:29:44


Fantastic!!

Many thanks.

I have scanned through the boost documentation for this library several times to find some clues. Did I miss anything there? I would like to know where I can find the section where this is documented for future reference.

Again thanks alot. You've been of great help.

Paul

-----Original Message-----
From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]]On Behalf Of Joaquín Mª
López Muñoz
Sent: woensdag 19 september 2007 12:28
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] Using multi-index as container type
intemplated class

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