Julius Ziegler | 4 Jul 18:12

[Boost.MultiIndex] Parameterizing multi_index_container on a template parameter

Hello,

I am having problems using a multi_index_container in the context of a 
template class, and I am hoping someone here can help me. This is a 
condensed example:

template<class T> struct C {
   typedef multi_index_container<T> SomeSet;
   SomeSet container;

   // I learned I need typename, since this is an implicit type
   typedef typename multi_index_container<T>::nth_index<0>::type 
SomeSetIndex;

   void f()
   {
     SomeSetIndex& index = container.get<0>();
   }
};

The typedef for SomeSetIndex did not compile. g++-4.2 reported (I 
stripped something from the message that I think is not relevant):

error: non-template 'nth_index' used as template
note: use 'multi_index_container<T, [stripped] >::template nth_index' to 
indicate that it is a template

Now I (blindly) tried this declaration:

typedef typename multi_index_container<T>::template nth_index<0>::type
(Continue reading)

Favicon
Gravatar

Re: [Boost.MultiIndex] Parameterizing multi_index_container on a template parameter

Hi Julius,

________________________________________
De: boost-users-bounces <at> lists.boost.org [boost-users-bounces <at> lists.boost.org] En nombre de
Julius Ziegler [ziegler <at> mrt.uka.de]
Enviado el: viernes, 04 de julio de 2008 18:16
Para: boost-users <at> lists.boost.org
Asunto: [Boost-users] [Boost.MultiIndex] Parameterizing multi_index_container on a template parameter

> Hello,
>
> I am having problems using a multi_index_container in the context of a
> template class, and I am hoping someone here can help me. This is a
> condensed example:
>
> template<class T> struct C {
>    typedef multi_index_container<T> SomeSet;
>    SomeSet container;
>
>    // I learned I need typename, since this is an implicit type
>    typedef typename multi_index_container<T>::nth_index<0>::type
> SomeSetIndex;
>
>    void f()
>    {
>      SomeSetIndex& index = container.get<0>();
>    }
> };
[...]

(Continue reading)

Julius | 6 Jul 13:35

Re: [Boost.MultiIndex] Parameterizing multi_index_container on a template parameter

That helped a lot, thank you very kindly!

-Julius

Gmane