Newbie using multi_index

Hello, I'm new in using the MultiIndex container of Boost 1.32.0. To get familiar with this library I wrote a small example. During the compilation with the Microsoft Visual C++ 7.1 compiler I encounter an internal compiler error. The error occurs, if I use the MultiIndex container with the following configuration: - Specification of tagged indices. - Specification of one composite_key template parameter. - Specification of at least three indices. Example: struct SFirst { }; struct SSecond { }; struct SBoth { }; typedef std::pair<std::wstring, std::wstring> Element_t; typedef multi_index_container<Element_t, indexed_by<ordered_non_unique<tag<SFirst>, member<Element_t, std::wstring, &Element_t::first> >, ordered_non_unique<tag<SSecond>, member<Element_t, std::wstring, &Element_t::second> >, ordered_unique<tag<SBoth>, composite_key<Element_t, member<Element_t, std::wstring, &Element_t::first>, member<Element_t, std::wstring, &Element_t::second> > > > > MultiIndex_t; //... int main(int argc, char** argv) { MultiIndex_t test; MultiIndex_t::index<SBoth>::type& both = test.get<SBoth>(); return 0; } If I compile this code I get the following internal compiler error: d:\Libraries\DLLs\Boost\Boost_1_32_0\inc\boost\tuple\detail\tuple_basic.hpp(612) : fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'msc1.cpp', line 2701) Please choose the Technical Support command on the Visual C++ Help menu, or open the Technical Support help file for more information If I try to access the first (#0) and second (#1) index with their respective tags, everything works fine. Also, I'm able to access all three indices by their numerical value without an error. Is the declaration of the MultiIndex_t typedef wrong? Regards, Jochen.

"Hammann, Jochen" wrote:
I'm new in using the MultiIndex container of Boost 1.32.0. To get familiar with this library I wrote a small example. During the compilation with the Microsoft Visual C++ 7.1 compiler I encounter an internal compiler error.
Example:
[snip] It is not complete (includes, using directives). Please post complete example and I will try with other compilers. /Pavel

Hammann, Jochen <Jochen.Hammann <at> realtech.com> writes:
Hello,
I'm new in using the MultiIndex container of Boost 1.32.0. To get familiar with this library I wrote a small example. During the compilation with the Microsoft Visual C++ 7.1 compiler I encounter an internal compiler error.
The error occurs, if I use the MultiIndex container with the following configuration: - Specification of tagged indices. - Specification of one composite_key template parameter. - Specification of at least three indices.
Example:
struct SFirst { }; struct SSecond { }; struct SBoth { };
typedef std::pair<std::wstring, std::wstring> Element_t;
typedef multi_index_container<Element_t, indexed_by<ordered_non_unique<tag<SFirst>, member<Element_t, std::wstring,
&Element_t::first> >,
ordered_non_unique<tag<SSecond>, member<Element_t, std::wstring,
&Element_t::second> >,
ordered_unique<tag<SBoth>, composite_key<Element_t, member<Element_t,
std::wstring, &Element_t::first>,
member<Element_t,
std::wstring, &Element_t::second> > > > > MultiIndex_t;
//...
int main(int argc, char** argv) { MultiIndex_t test;
MultiIndex_t::index<SBoth>::type& both = test.get<SBoth>();
return 0; }
If I compile this code I get the following internal compiler error:
d:\Libraries\DLLs\Boost\Boost_1_32_0\inc\boost\tuple\detail\tuple_basic.hpp
(612) : fatal
error C1001: INTERNAL COMPILER ERROR (compiler file 'msc1.cpp', line 2701) Please choose the Technical Support command on the Visual C++ Help menu, or open the Technical Support help file for more information
If I try to access the first (#0) and second (#1) index with their respective tags, everything works fine. Also, I'm able to access all three indices by their numerical value without an error.
Is the declaration of the MultiIndex_t typedef wrong?
Hi, Jochen. As Pavel says, it'd be great if you can post a complete snippet showing the crash, so that we can try compiling it in other platforms. In the meantime, though, my hunch is that the compiler is having a hard time with the length of the symbol names generated by your definition (once expanded, it gets pretty long.) This of course is not your fault. Please try the following: ... typedef composite_key<Element_t,...> SBothKeyExtractor_t; typedef multi_index_container<Element_t, indexed_by< ordered_non_unique<tag<SFirst>,...> ordered_non_unique<tag<SSecond>,...> ordered_unique<tag<SBoth>, SBothKeyExtractor_t>
MultiIndex_t;
if this still doesn't work, try then struct SBothKeyExtractor_t: public composite_key<Element_t,...> { }; // as before which definitely shortens the symbol names for the types generated by your program. Oh, and please report your results (thank you!) Hope this helps, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

Hello Joaquín, Hello Pavel, thank you for your responses.
typedef composite_key<Element_t,...> SBothKeyExtractor_t; typedef multi_index_container<Element_t, indexed_by< ordered_non_unique<tag<SFirst>,...> ordered_non_unique<tag<SSecond>,...> ordered_unique<tag<SBoth>, SBothKeyExtractor_t>
MultiIndex_t;
The typedef SBothKeyExtractor_t causes an internal compiler error of the Visual C++ 7.1 Compiler, too. d:\Libraries\DLLs\Boost\Boost_1_32_0\inc\boost\tuple\detail\tuple_basic.hpp(612): fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'msc1.cpp', line 2701) Please choose the Technical Support command on the Visual C++ Help menu, or open the Technical Support help file for more information
if this still doesn't work, try then
struct SBothKeyExtractor_t: public composite_key<Element_t,...> { };
// as before
The declaration of the struct fixes the problem. Now, I'm able to build the example without an error. Thanks a lot. For completeness. Below is the whole source code of my initial example, which causes the internal compiler error: #include <string> #include <boost/multi_index_container.hpp> #include <boost/multi_index/member.hpp> #include <boost/multi_index/ordered_index.hpp> #include <boost/multi_index/sequenced_index.hpp> #include <boost/multi_index/key_extractors.hpp> using boost::multi_index_container; using namespace boost::multi_index; struct SSequence { }; struct SFirst { }; struct SSecond { }; struct SBoth { }; typedef std::pair<std::wstring, std::wstring> Element_t; typedef multi_index_container<Element_t, indexed_by<ordered_non_unique<tag<SFirst>, member<Element_t, std::wstring, &Element_t::first> >, ordered_non_unique<tag<SSecond>, member<Element_t, std::wstring, &Element_t::second> >, ordered_unique<tag<SBoth>, composite_key<Element_t, member<Element_t, std::wstring, &Element_t::first>, member<Element_t, std::wstring, &Element_t::second> > > > > MultiIndex_t; int main(int argc, char** argv) { using namespace std; using namespace boost; MultiIndex_t test; MultiIndex_t::index<SBoth>::type& both = test.get<SBoth>(); return 0; } Regards, Jochen.

"Jochen Hammann" wrote: [snip]
For completeness. Below is the whole source code of my initial example, which causes the internal compiler error:
[snip] Compiles and runs cleanly on Intel C++ 7.0 plugged in VC6 IDE. One option for you is to get Intel C++ (latest version is 8.1 or so) and install it as plugin into VC7.1. It is seamless and reversible. /Pavel

Compiles and runs cleanly on Intel C++ 7.0 plugged in VC6 IDE.
One option for you is to get Intel C++ (latest version is 8.1 or so) and install it as plugin into VC7.1. It is seamless and reversible.
Thank you very much for your help and the advice with the Intel C++ compiler. Regards, Jochen.
participants (4)
-
Hammann, Jochen
-
Joaquin M Lopez Munoz
-
Jochen Hammann
-
Pavel Vozenilek