Re: [Boost-users] Using multi-index as container type in templated class
Hi Paul, Paul.VanHagen@shell.com 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
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@lists.boost.org [mailto:boost-users-bounces@lists.boost.org]On Behalf Of Joaquín Mª López Muñoz Sent: woensdag 19 september 2007 12:28 To: boost-users@lists.boost.org Subject: Re: [Boost-users] Using multi-index as container type intemplated class Hi Paul, Paul.VanHagen@shell.com 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
Joaquín Mª López Muñoz ha escrito:
Hi Paul,
[...]
So, instead of
typedef typename mi::nth_index<0>::type mi_by_value;
you can write
typedef typename nth_index
::type mi_by_value;
Hello Paul, upon concidentally revisiting this same problem when answering the post at http://lists.boost.org/boost-users/2007/09/30953.php , I've realized that GCC has no issues with dependent nested types, the problem is that you were missing a dependent template keyword: typedef typename mi::template nth_index<0>::type mi_by_value; Of course, the resort to global nth_index<...> is also valid. Sorry for the confusion, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
participants (2)
-
Joaquín Mª López Muñoz
-
Paul.VanHagen@shell.com