Boost logo

Boost Users :

Subject: Re: [Boost-users] multi-index-container with nested templates => problem getting iterator on 2nd index.
From: JohnQ (jqs_at_[hidden])
Date: 2009-05-13 19:59:42


>
>
> > 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.

Yes, I've been ignoring this while I figured out the iterator... it's
leftover from the example and I just named things first,second,third while I
get the rest figured out. What I did instead was use the structure below...
I didn't want to mess with stuff like tuple_element<N>::template get<RET>(x)
(or whatever the correct type-independent tuple-element accessor would be)
becuase I'm really not that familiar with this sort of meta programming...
this seems like it will work but if you're familiar with a better way, I'd
love to hear about it.

template <typename T1, typename T2, typename T3>
struct bimultimap_triple
{
typedef T1 first_type;
typedef T2 second_type;
typedef T3 third_type;

bimultimap_triple():first(T1()),second(T2()),third(T3()){}
bimultimap_triple(const T1& f,const T2& s, const T3&
t):first(f),second(s),third(t){}

T1 first;
T2 second;
T3 third;
};

>
> [...]
> > 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;

That compiles (BIG THANK YOU). Next step is for me to figure out what this
actually does. :) Can you give me some background (or point me to the
correct reading material) on why the "template" qualifier is needed and what
effect that has? I need to learn more about this...

>
> Hope this helps. Thanks for using Boost.MultiIndex,

Definitely helped. Thanks. :)

>
>
> Joaquín M López Muñoz
> Telefónica, Investigación y Desarrollo
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users



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