Boost logo

Boost Users :

Subject: Re: [Boost-users] multi-index-container with nested templates => problem getting iterator on 2nd index.
From: Joaquin M Lopez Munoz (joaquin_at_[hidden])
Date: 2009-05-13 16:38:00

Hi Joh,

JohnQ <jqs <at>> writes:

> Hi, I'm really stuck on this one, so I'm hoping someone can lend me a hand.
> Basically, I'm defining a templated multi-index-container to hold one piece
> of data along with two indexes to that data. Next, I'm wrapping that in
> another templated class that will handle concurrent access to that structure.
> My problem is that I'm having trouble figuring out how to define a type
> that will give me an interator on the 2nd index of the multi-index-container
> ("bimimapIterator2" below).
> [...]
>   typedef boost::multi_index_container<
>     value_type,
>     indexed_by<
>       ordered_non_unique<
>         tag<index1>,member<value_type,Key1,&value_type::first> >,

This cannot possibly work, as value_type does not have a
member called first (you're using a tuple, not an std::pair).
Anyway, the problem does not lie here.

> typedef typename bimultimap<Key1,Key2,Data>::
> bimimap::index<index2>::type::iterator bimimapIterator2;

You need a disambiguating template keyword:

         typedef typename bimultimap<Key1,Key2,Data>::
          bimimap::template index<index2>::type::iterator bimimapIterator2;

Hope this helps. Thanks for using Boost.MultiIndex,

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

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at