________________________________________ De: boost-users-bounces@lists.boost.org [boost-users-bounces@lists.boost.org] En nombre de Igor R [boost.lists@gmail.com] Enviado el: lunes, 07 de julio de 2008 16:53 Para: boost-users@lists.boost.org Asunto: Re: [Boost-users] [boost-users][Multi-Index] crash in equal_range()
Well, I think I've realised what happed there:
RecordsBySetting bySetting = records_.getRecord::setting();
The index is copied there, and the copy is in invalid state for some reason. However, if take the reference, everything goes well:
RecordsBySetting &bySetting = records_.getRecord::setting();
Hi Igor, Correct, the problem was exactly as you said: indices are not meant to be copied and can only be referred to to via references (or pointers). You might legitimately ask: why haven't you made their copy ctors private/protected so as to avoid this kind of errors? Well, the copy ctors are indeed protecetd except for those *defective* compilers for which the Boost.Config macro BOOST_NO_MEMBER_TEMPLATE_FRIENDS is set, among which are MSVC 8.0 and older (which I guess include the one you're using). This issue gets reported every so often, see for instance an older post about it: http://lists.boost.org/boost-users/2005/02/10055.php To try to prevent new users from keep falling into the same trap I added some warning text at the last paragraph of http://www.boost.org/libs/multi_index/doc/tutorial/basics.html#multiple_sort Unfortunately, the caveat seems not to be conspicuous enough, judging from the number of times this problem has been reported. I'm sorry it also hit you, hope your further experience with B.MI is more pleasant. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo