4 Jul 18:12
[Boost.MultiIndex] Parameterizing multi_index_container on a template parameter
From: Julius Ziegler <ziegler <at> mrt.uka.de>
Subject: [Boost.MultiIndex] Parameterizing multi_index_container on a template parameter
Newsgroups: gmane.comp.lib.boost.user
Date: 2008-07-04 16:16:09 GMT
Subject: [Boost.MultiIndex] Parameterizing multi_index_container on a template parameter
Newsgroups: gmane.comp.lib.boost.user
Date: 2008-07-04 16:16:09 GMT
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
g++ gets past it, but now reports a syntax error in function f, when
index gets initialised.
Can someone please explain that first error message to me? Any help is
appreciated.
-J
RSS Feed